Part Number Hot Search : 
BD240 MT390 OXFW971 BPC350 BTA64 LC150 51013 VHC1G0
Product Description
Full Text Search
 

To Download W79E201A16FN Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  w79e201 data sheet 8-bit microcontroller publication release date: december 16, 2004 - 1 - revision a2 table of contents- 1. general des cription ......................................................................................................... 3 2. features ....................................................................................................................... .......... 3 3. pin config urati on .............................................................................................................. .4 4. pin descri ption................................................................................................................ ..... 5 5. block di agram .................................................................................................................. .... 6 6. functional des cription ................................................................................................... 7 7. memory orga nization ....................................................................................................... 8 8. instruct ion.................................................................................................................... ...... 32 8.1 instruction timing ......................................................................................................... 32 9. power mana gement .......................................................................................................... 38 10. interrup ts ..................................................................................................................... ...... 41 11. programmable time rs/count ers ............................................................................... 42 11.1 timer/counter s 0 & 1.................................................................................................... 42 11.2 timer/count er 2............................................................................................................ 45 12. watchdog timer................................................................................................................. 48 13. serial port .................................................................................................................... ...... 51 13.1 framing error detection ............................................................................................... 56 13.2 multiprocessor co mmunicati ons .................................................................................. 56 14. pulse width modulated outputs (pwm) ................................................................... 58 15. analog-to-digital conver ter ...................................................................................... 60 16. timed access pr otection .............................................................................................. 63 17. h/w reboot mode (boot from 4k bytes of ld fl ash eprom)............................. 64 18. in-system pr ogrammi ng ................................................................................................. 65 18.1 the loader program locates at ld flash eprom memory....................................... 65 18.2 the loader program locates at ap flash eprom memory....................................... 65 19. h/w writer mode ................................................................................................................ 65 20. security bits .................................................................................................................. ..... 66 21. the performance charact eristic of adc .............................................................. 67 21.1 the differential nonlinear ity vs output code............................................................... 67 21.2 the integral nonlinear ity vs output code .................................................................... 68
w79e201 - 2 - 22. the embedded ice with jtag inte rface .................................................................... 68 23. electrical chara cteristi cs......................................................................................... 69 23.1 absolute maxi mum rati ngs .......................................................................................... 69 23.2 dc characteri stics........................................................................................................ 69 23.3 adc dc electrical c haracterist ics ............................................................................... 71 23.4 ac characte ristics ........................................................................................................ 71 24. typical applicat ion circui ts ........................................................................................ 77 25. package dime nsions ......................................................................................................... 79 26. applicatio n no te ............................................................................................................... 81 27. revision history ............................................................................................................... .87
w79e201 publication release date: december 16, 2004 - 3 - revision a2 1. general description the w79e201 is a fast 8051 compatible microcontro ller with a redesigned processor core without wasted clock and memory cycles. the w79e201 c ontains in-system programmable (isp) 16 kb ap flash eprom; 4kb ld flash eprom for loader progr am; a 256 bytes of ram; one 8-bit digital or analog input port (port 1); three 8-bit bi-directional and bit-addressable i/o ports; an 1-bit port p4.0 for external isp reboot used; three 16-bit timer/c ounters; one serial ports. these peripherals are supported by 8 sources two-level interrupt capabilit y. to facilitate programming and verification, the flash eprom inside the w79e201 allows the program memory to be programmed and read electronically. once the code is confirmed, the user can protect the code for security. the w79e201 is added 10-bit adc with an 8 channel analog input wi th digital input port. furthermore, the w79e201a16ln, packaged in 48-pin lqfp, supports the in circuit emulation (ice) function with jtag interface to the development tool. the w 79e201 executes every 8051 in struction faster than the original 8051 for the same crystal speed. typica lly, the instruction execut ing time of w79e201 is 1.5 to 3 times faster than that of traditional 8051, depending on the type of inst ruction. in general, the overall performance is about 2.5 times better than the original for the same crystal speed. giving the same throughput with lower clock speed, power consumption has been impr oved. consequently, the w79e201 is a fully static cmos design; it c an also be operated at a lower crystal clock. 2. features ? fully static design 8-bit turbo 51 cmos microcontroller up to 16mhz ? 16k bytes of in-system-progra mmable flash eprom (ap flash eprom) ? 4kb auxiliary flash eprom for loader program (ld flash eprom) ? 256 bytes of on-chip ram ? instruction-set compatible with msc-51 ? on-chip debug function with jtga interface to development tool ? three 8-bit bi-directional ports ? three 16-bit timer/counters ? 8 interrupt source with two levels of priority ? one enhanced full duplex serial port with framing error detection and automatic address recognition ? port 0 internal pull-up resistor optional ? programmable watchdog timer ? 6 channel pwm ? software programmable access cycle to external ram/peripherals ? 10-bits adc with 8 channel analog input or digi tal input port (at least 8-bits resolution guaranteed) ? packages: ? plcc 44: w79e201a16pn ? qfp 44: W79E201A16FN ? lqfp 48: w79e201a16ln
w79e201 - 4 - 3. pin configuration 48-pin lqfp 44-pin plcc 44-pin qfp 34 40 39 38 37 36 35 44 43 42 41 33 32 31 30 29 28 27 26 25 24 23 p0.4, ad4 p0.5, ad5 p0.6, ad6 p0.7, ad7 ea ale psen p2.7, a15 p2.6, a14 p2.5, a13 22 21 20 19 18 17 16 15 14 13 12 11 4 3 2 1 8 7 6 5 10 9 p1.4 p1.5 p1.6 rst rxd, p3.0 p1.7 txd, p3.1 int0, p3.2 int1, p3.3 t0, p3.4 t1, p3.5 x t a l 1 v s s p 2 . 4 , a 1 2 p 2 . 3 , a 1 1 p 2 . 2 , a 1 0 p 2 . 1 , a 9 p 2 . 0 , a 8 x t a l 2 p 3 . 7 , / r d p 3 . 6 , / w r 40 2 1 44 43 42 41 6543 39 38 37 36 35 34 33 32 31 30 29 p0.4, ad4 p0.5, ad5 p0.6, ad6 p0.7, ad7 ea ale psen p2.7, a15 p2.6, a14 p2.5, a13 28 27 26 25 24 23 22 21 20 19 18 17 10 9 8 7 14 13 12 11 16 15 p1.4 p1.5 p1.6 rst rxd, p3.0 p1.7 txd, p3.1 int0, p3.2 int1, p3.3 t0, p3.4 t1, p3.5 x t a l 1 v s s p 2 . 4 , a 1 2 p 2 . 3 , a 1 1 p 2 . 2 , a 1 0 p 2 . 1 , a 9 p 2 . 0 , a 8 x t a l 2 p 3 . 7 , / r d p 3 . 6 , / w r a d 2 , p 0 . 2 v r e f p 1 . 1 v s s a d 1 , p 0 . 1 a d 0 , p 0 . 0 p 1 . 0 p 1 . 2 p 1 . 3 a d 2 , p 0 . 2 v r e f p 1 . 1 v s s a d 1 , p 0 . 1 a d 0 , p 0 . 0 a d p 1 . 0 p 1 . 2 p 1 . 3 p0.3, ad3 v d d v d d a a 0 p 4 . p0.3, ad3 d v a d d v p 4 . 0 34 44 43 42 37 36 35 48 47 46 45 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 4 3 2 1 8 7 6 5 10 9 p2.3, a11 p1.4 41 40 39 38 p2.4, a12 p2.5, a13 p2.6, a14 p2.7, a15 psen ale ea p0.7, ad7 p0.6, ad6 p0.5, ad5 p0.4, ad4 p p pp p p p p v v v v 0 0 0 0 d d s s a d d a r e f 1 1 1 1 . . . . 3 2 1 0 .. . . 0 12 3 p1.5 p1.6 p1.7 reset p3.0, rxd p3.1, txd p3.2, int0 p3.3, int1 p3.4, t0 p3.5, t1 p3.6, wr d r / , 7 . 3 p 2 1 l l a a t t x x s s v 0 . 4 p k c t s m t i d t o d t 8 9 0 1 aa a , , , 0 1 2 2 . . . 2 2 p p p , , , , a aa a d dd d 3 2 1 0 w79e201a16pn W79E201A16FN w79e201a16ln
w79e201 publication release date: december 16, 2004 - 5 - revision a2 4. pin description symbol type descriptions ea i h external access enable: this pin forces the processor to execute out of external rom. it should be kept high to access internal rom. the rom address and data will not be present on the bus if e a pin is high and the program counter is within 16kb area. otherwise they will be present on the bus. psen o h program store enable: psen enables the external rom data onto the port 0 address/data bus during fetch and movc operations. when internal rom access is performed, no psen strobe signal outputs from this pin. ale o h address latch enable: ale is used to enable the address latch that separates the address from the data on port 0. rst i l reset: a high on this pin for two machine cycles while the oscillator is running resets the device. xtal1 i crystal1: this is the crystal oscillator input. this pin may be driven by an external clock. xtal2 o crystal2: this is the crystal oscillator out put. it is the inversion of xtal1. vss p digital ground: ground potential vdd p digital power supply: supply voltage for operation. avdd p analog power supply: supply analog voltage for operation. avss p ground: analog ground potential vref p vref: analog reference input maximum voltage for adc p0.0 ? p0.7 i/o d(h) port 0: port 0 is an open-drain bi-directi onal i/o port with internal pull-up resister option that is enabled by setting bi t 0 of p0r(8fh) to logic high. this port also provides a multiplexed low order address/data bus during accesses to external memory. p1.0 ? p1.7 i port 1: port 1 is an input port. or with an 8-bit analog input port for adc0- adc7(8 analog input channels) used. p2.0 ? p2.7 i/o port 2: port 2 is a bi-directional i/o port with internal weakly pull-ups. this port also provides the upper address bits for accesses to external memory. p3.0 ? p3.7 i/o port 3: port 2 is a bi-directional i/o por t with internal weakly pull-ups. function is the same as that of the standard 8052. p4.0 i/o port 4: a bi-directional i/o port with in ternal with weakly pull-ups tck i l tck: jtag test clock tms i h tms: jtag test mode select tdi i h tdi: jtag test data in tdo o tdo: jtag test data out * note: type p: power, i: input, o: output, i/o: bi-directi onal, h: pull-high, l: pull-low, d: open drain .
w79e201 - 6 - 5. block diagram address bus p3.0 p3.7 p1.0 p1.7 alu port 0 latch port 1 latch timer 1 timer 0 port 0 port 1 1 uart xtal1 psen ale gnd v cc rst xtal2 oscillator interrupt psw instruction decoder & sequencer reset block bus & lock controller sfr ram address power control & power monitor 256 bytes ram & sfr stack pointer b addr. reg. incrementor pc temp reg. t2 register t1 register acc port 3 latch port 3 p0.0 p0.7 port 2 latch port 2 p2.0 p2.7 timer 2 dptr watchdog timer port 4 latch port 4 p4.0 adc flash eprom
w79e201 publication release date: december 16, 2004 - 7 - revision a2 6. functional description the w79e201 is not pin compatible with 8052 but t he instruction set is compatible. it includes the resources of the standard 8052 such as three 8-bit i/o ports, one 8-bit digital or analog input port, three 16-bit timer/counters, one full duplex serial port and interrupt sources. the w79e201 features a faster running and better performance 8-bit cpu with a redesigned core processor without wasted clock and memory cycles. it improves t he performance not just by running at high frequency but also by reducing the machi ne cycle duration from the standard 8052 period of twelve clocks to four clock cycles for the majority of instructions. this improves performance by an average of 1.5 to 3 times. it can also adjust the dur ation of the movx instruction (access to off-chip data memory) between two machine cycles and nine machine cycles. this flexibility allows the w79e201 to work efficiently with both fa st and slow rams and peripheral devices. the w79e201 is an 8052 compatible device that give s the user the features of the original 8052 device, but with improved speed and power consumpti on characteristics. it has the same instruction set as the 8051 family. while the original 8051 fam ily was designed to operate at 12 clock periods per machine cycle, the w79e201 operates at a much reduced clock rate of only 4 clock periods per machine cycle. this naturally speeds up the ex ecution of instructions . consequently, the w79e201 can run at a higher speed as compared to the origi nal 8052, even if the same crystal is used. since the w79e201 is a fully static cmos design, it can also be operated at a lower crystal clock, giving the same throughput in terms of instruction exec ution, yet reducing the power consumption. the 4 clocks per machine cycle feature in the w79e 201 is responsible for a three-fold increase in execution speed. the w79e201 has all the standar d features of the 8052, and has a few extra peripherals and features as well. i/o ports the w79e201 has one 8-bit digital or analog input por t, three 8-bit i/o ports and one extra 1-bit port at p4.0. port 0 can be used as an address/data bus when external program is running or external memory/device is accessed by movc or movx instru ction. in these cases, it has strong pull-ups and pull-downs, and does not need any external pull-ups. otherwise it can be used as a general i/o port with open-drain circuit. port 2 is used chiefly as the upper 8-bits of the address bus when port 0 is used as an address/data bus. it also has strong pull- ups and pull-downs when it serves as an address bus. port 1 is only input port which can be selected to 8-channel analog input pins of adc. port 3 act as i/o ports with alternate func tions. port 4.0 serves as a general purpose i/o port as port 3. serial i/o the w79e201 has one enhanced serial port that is functiona lly similar to the serial port of the original 8052 family. however the serial port on the w79e201 c an operate in different modes in order to obtain timing similarity as well. the serial port has t he enhanced features of automatic address recognition and frame error detection. timers the w79e201 has three 16-bit timers that are functi onally similar to the timers of the 8052 family. when used as timers, they can be set to run at eit her 4 clocks or 12 clocks per count, thus providing the user with the option of operating in a mode t hat emulates the timing of the original 8052. the w79e201 has an additional feature, the watchdog timer. th is timer is used as a system monitor or as a very long time period timer.
w79e201 - 8 - interrupts the interrupt structure in the w79e 201 is slightly different from t hat of the standard 8052. due to the presence of additional features and peripherals, t he number of interrupt sources and vectors has been increased. the w79e201 provides 8 interrupt resource s with two priority levels, including 2 external interrupt sources, 3 timer interrupts, 1 serial i/o interrupt, 1 adc interrupt and 1 watch dog timer interrupt. power management like the standard 80c52, the w79e201 also has id le and power down modes of operation. in the power down mode, all of the clocks of peripheral are stopped and the chip operation is completely stopped. this is the lo west power consumption state. 7. memory organization the w79e201 separates the memory into two separ ate sections, the program memory and the data memory. the program memory is used to store the instruction op-codes, while the data memory is used to store data or for memory mapped devices. program memory the program memory on the standard 8052 can only be addr essed to 64 kbytes long. all instructions are fetched for execution from this memory area. t he movc instruction can also access this memory region. there is an auxiliary 4kb flash eprom bank (ld flash eprom) resided user loader program for in-system programming (isp). the ap fl ash eprom allows serial or parallel download according to user loader progr am in ld flash eprom. data memory the w79e201 can access up to 64kbytes of external data memory. this memory region is accessed by the movx instructions. any movx directed to the space between 0000h and ffffh goes to the expanded bus on port 0 and 2. this is the defaul t condition. in addition, the w79e201 has the standard 256 bytes of on-chip scratchpad ram. this can be accessed either by direct addressing or by indirect addressing. there are also some s pecial function registers (sfrs), which can only be accessed by direct addressing. since the scra tchpad ram is only 256 bytes, it can be used only when data contents are small. 0000h ffffh 80h 7fh 00h indirect addressing ram direct & indirect addressing ram sfrs direct addressing ffh ap flash eprom 0fffh 4k bytes ld flash eprom 16k bytes on-chip program memory 64k bytes external data memory 3fffh memory map
w79e201 publication release date: december 16, 2004 - 9 - revision a2 special function registers the w79e201 uses special function registers (sfr s) to control and monitor peripherals and their modes. the sfrs reside in the register locations 80-ffh and are accessed by direct addressing only. some of the sfrs are bit addressable. this is very usef ul in cases where one wishes to modify a particular bit without changing the others. t he sfrs that are bit addressable are those whose addresses end in 0 or 8. the w79e201 contains all the sfrs pres ent in the standard 8052. however, some additional sfrs have been added. in some cases unused bits in the original 8052 have been given new functions. the list of sfrs is as follows. the table is condensed with eight locations per row. empty locations indicate that there are no registers at these addresses. when a bit or register is not implemented, it will read high. table 1. special function register location table f8 eip f0 b e8 eie e0 acc adccon adch adccen d8 wdcon pwmp pwm0 pwm1 pwmcon 1 pwm2 pwm3 d0 psw c8 t2con t2mod rcap2l rcap2h tl2 th2 pwmcon 2 pwm4 c0 pwm5 pmr status ta b8 ip saden b0 p3 a8 ie saddr sfral sfrah sfrfd sfrcn a0 p2 p4 98 scon sbuf chpcon 90 p1 88 tcon tmod tl0 tl1 th0 th1 ckcon p0r 80 p0 sp dpl dph pcon note: the sfrs in the column wi th dark borders are bit-addressable.
w79e201 - 10 - port 0 bit: 7 6 5 4 3 2 1 0 p0.7 p0.6 p0.5 p0.4 p0.3 p0.2 p0.1 p0.0 mnemonic: p0 address: 80h port 0 is an open-drain bi-directional i/o port. this port also provides a multiplexed low order address/data bus during accesses to external memory. stack pointer bit: 7 6 5 4 3 2 1 0 sp.7 sp.6 sp.5 sp.4 sp.3 sp.2 sp.1 sp.0 mnemonic: sp address: 81h the stack pointer stores the scratchpad ram addre ss where the stack begins. in other words, it always points to the top of the stack. data pointer low bit: 7 6 5 4 3 2 1 0 dpl.7 dpl.6 dpl.5 dpl.4 d pl.3 dpl.2 dpl.1 dpl.0 mnemonic: dpl address: 82h this is the low byte of the standard 8052 16-bit data pointer. data pointer high bit: 7 6 5 4 3 2 1 0 dph.7 dph.6 dph.5 dph.4 d ph.3 dph.2 dph.1 dph.0 mnemonic: dph address: 83h this is the high byte of the standard 8052 16-bit data pointer. power control bit: 7 6 5 4 3 2 1 0 sm0d smod0 - - gf1 gf0 pd idl mnemonic: pcon address: 87h bit name function 7 smod 1: this bit doubles the serial port baud rate in mode 1, 2, and 3. 6 smod0 0: framing error detection disable. sc on.7 acts as per the standard 8052 function. 1: framing error detection enable, t hen and scon.7 indicates a frame error and acts as the fe flag. 5 - reserve
w79e201 publication release date: december 16, 2004 - 11 - revision a2 continued bit name function 4 - reserve 3 gf1 general purpose user flag. 2 gf0 general purpose user flag. 1 pd 1: setting this bit causes the chip to go into the power down mode. in this mode all the clocks are stopped and program execution is frozen. 0 idl 1: setting this bit causes the chip to go in to the idle mode. in this mode the clocks to the cpu are stopped, so progr am execution is frozen. but the clock to the serial port, adc, timer and interrupt blocks is not stopped, and these blocks continue operating. timer control bit: 7 6 5 4 3 2 1 0 tf1 tr1 tf0 tr0 ie1 it1 ie0 it0 mnemonic: tcon address: 88h bit name function 7 tf1 timer 1 overflow flag: this bit is se t when timer 1 overflows. it is cleared automatically when the program does a time r 1 interrupt service routine. software can also set or clear this bit. 6 tr1 timer 1 run control: this bit is set or cl eared by software to turn timer/counter on or off. 5 tf0 timer 0 overflow flag: this bit is se t when timer 0 overflows. it is cleared automatically when the program does a time r 0 interrupt service routine. software can also set or clear this bit. 4 tr0 timer 0 run control: this bit is set or cl eared by software to turn timer/counter on or off. 3 ie1 interrupt 1 edge detect: set by har dware when an edge/level is detected on int1 . this bit is cleared by hardware when the se rvice routine is vectored to only if the interrupt was edge triggered. otherwise it follows the pin. 2 it1 interrupt 1 type control: set/cleared by software to specify falling edge/ low level triggered external inputs. 1 ie0 interrupt 0 edge detect: set by har dware when an edge/level is detected on int0 . this bit is cleared by hardware when the se rvice routine is vectored to only if the interrupt was edge triggered. otherwise it follows the pin. 0 it0 interrupt 0 type control: set/cleared by software to specify falling edge/ low level triggered external inputs.
w79e201 - 12 - timer mode control bit: 7 6 5 4 3 2 1 0 gate t c/ m1 m0 gate t c/ m1 m0 mnemonic: tmod address: 89h bit name function 7 gate gating control: when this bit is se t, timer/counter x is enabled only while int x pin is high and trx control bit is set. when cleared, timer x is enabled whenever trx control bit is set. 6 t c/ timer or counter select: when cleared, the timer is incremented by internal clocks. when set, the timer counts high-to-low edges of the tx pin. 5 m1 mode select bit. 4 m0 mode select bit. 3 gate gating control: when this bit is se t, timer/counter x is enabled only while intx pin is high and trx control bit is set. when cleared, timer x is enabled whenever trx control bit is set. 2 t c/ timer or counter select: when cleared, the timer is incremented by internal clocks. when set, the timer counts high-to-low edges of the tx pin. 1 m1 mode select bit. 0 m0 mode select bit. m1, m0: mode select bits: m1 m0 mode 0 0 mode 0: 8-bits with 5-bit prescale. 0 1 mode 1: 18-bits, no prescale. 1 0 mode 2: 8-bits with auto-reload from thx 1 1 mode 3: (timer 0) tl0 is an 8-bit timer/ counter controlled by the standard timer 0 control bits. th0 is an 8-bit timer only cont rolled by timer 1 control bits. (timer 1) timer/counter is stopped. timer 0 lsb bit: 7 6 5 4 3 2 1 0 tl0.7 tl0.6 tl0.5 tl0.4 tl0.3 tl0.2 tl0.1 tl0.0 mnemonic: tl0 address: 8ah tl0.7 ? 0: timer 0 lsb
w79e201 publication release date: december 16, 2004 - 13 - revision a2 timer 1 lsb bit: 7 6 5 4 3 2 1 0 tl1.7 tl1.6 tl1.5 tl1.4 tl1.3 tl1.2 tl1.1 tl1.0 mnemonic: tl1 address: 8bh tl1.7 ? 0: timer 1 lsb timer 0 msb bit: 7 6 5 4 3 2 1 0 th0.7 th0.6 th0.5 th0.4 th0.3 th0.2 th0.1 th0.0 mnemonic: th0 address: 8ch th0.7 ? 0: timer 0 msb timer 1 msb bit: 7 6 5 4 3 2 1 0 th1.7 th1.6 th1.5 th1.4 th1.3 th1.2 th1.1 th1.0 mnemonic: th1 address: 8dh th1.7 ? 0: timer 1 msb clock control bit: 7 6 5 4 3 2 1 0 wd1 wd0 t2m t1m t0m md2 md1 md0 mnemonic: ckcon address: 8eh bit name function 7 wd1 watchdog timer mode select bit 1: these bits determine the time-out period for the watchdog timer. in all four time-out options the reset time-out is 512 clocks mo re than the interrupt time-out period. 6 wd0 watchdog timer mode select bit 0: these bits determine the time-out period for the watchdog timer. in all four time-out options the reset time-out is 512 clocks mo re than the interrupt time-out period. 5 t2m timer 2 clock select: when t2m is set to 1, timer 2 uses a divide by 4 clock, and when set to 0 it uses a divide by 12 clock.
w79e201 - 14 - continued bit name function 4 t1m timer 1 clock select: when t1m is set to 1, timer 1 uses a divide by 4 clock, and when set to 0 it uses a divide by 12 clock. 3 t0m timer 0 clock select: when t0m is set to 1, timer 0 uses a divide by 4 clock, and when set to 0 it uses a divide by 12 clock. 2 md2 stretch movx select bit 2: these three bits are used to select the st retch value for the movx instruction. using a variable movx length enables the user to access slower external memory devices or peripherals without the need for external circuits. the rd or wr strobe will be stretched by the selected interval. w hen accessing the on-chip sram, the movx instruction is always in 2 machine cycl es regardless of the stretch setting. by default, the stretch has value of 1. if the user needs faster accessing, then a stretch value of 0 should be selected. 1 md1 stretch movx select bit 1: these three bits are used to select the st retch value for the movx instruction. using a variable movx length enables the user to access slower external memory devices or peripherals without the need for external circuits. the rd or wr strobe will be stretched by the selected interval. w hen accessing the on-chip sram, the movx instruction is always in 2 machine cycl es regardless of the stretch setting. by default, the stretch has value of 1. if the user needs faster accessing, then a stretch value of 0 should be selected. 0 md0 stretch movx select bit 0: these three bits are used to select the st retch value for the movx instruction. using a variable movx length enables the user to access slower external memory devices or peripherals without the need for external circuits. the rd or wr strobe will be stretched by the selected interval. w hen accessing the on-chip sram, the movx instruction is always in 2 machine cycl es regardless of the stretch setting. by default, the stretch has value of 1. if the user needs faster accessing, then a stretch value of 0 should be selected. wd1 wd0 interrupt time-out reset time-out 0 0 2 17 2 17 + 512 0 1 2 20 2 20 + 512 1 0 2 23 2 23 + 512 1 1 2 26 2 26 + 512
w79e201 publication release date: december 16, 2004 - 15 - revision a2 md2 md1 md0 stretch value movx duration 0 0 0 0 2 machine cycles 0 0 1 1 3 machine cycles (default) 0 1 0 2 4 machine cycles 0 1 1 3 5 machine cycles 1 0 0 4 6 machine cycles 1 0 1 5 7 machine cycles 1 1 0 6 8 machine cycles 1 1 1 7 9 machine cycles port 0 pull-up resister bit: 7 6 5 4 3 2 1 0 - - - - - - - p0up mnemonic: p0r address: 8fh bit name function 7~1 - reserved 0 p0up port 0 pull-up resistor 0: no pull-up resister 1: pull-up resister(~10k ? ) port 1 bit: 7 6 5 4 3 2 1 0 p1.7 p1.6 p1.5 p1.4 p1.3 p1.2 p1.1 p1.0 mnemonic: p1 address: 90h p1.7 ? 0: general purpose digital input port or analog i nput port, ad0~ad7. by the digital input port, most instructions will read the port pins in case of a port read access, however in case of read instructions, the port latch is read. t he alternate functions are described below: bit name function 1 p1.1 t2 : external input for timer/counter 2 0 p1.0 t2ex : timer/counter 2 capture/reload trigger
w79e201 - 16 - serial port control bit: 7 6 5 4 3 2 1 0 sm0/fe sm1 sm2 ren tb8 rb8 ti ri mnemonic: scon address: 98h bit name function 7 sm0/fe serial port, mode 0 bit or framing error flag: the smod0 bit in pcon sfr determines whether this bit acts as sm 0 or as fe. the operation of sm0 is described below. when used as fe, this bit will be set to indicate an invalid stop bit. this bit must be manually cleared in software to clear the fe condition. 6 sm1 serial port mode bit 1: mode: sm0 sm1 description length baud rate 0 0 0 synchronous 8 4/12 tclk 1 0 1 asynchronous 10 variable 2 1 0 asynchronous 11 64/32 tclk 3 1 1 asynchronous 11 variable 5 sm2 multiple processors communication. setting this bit to 1 enables the multiprocessor communication feature in mode 2 and 3. in mode 2 or 3, if sm2 is set to 1, then ri will not be activated if the received 9th data bit (rb8) is 0. in mode 1, if sm2 = 1, then ri will not be activated if a valid stop bit was not received. in mode 0, the sm2 bit controls the serial port clock. if set to 0, then the serial port runs at a divide by 12 clock of the oscillator. this give s compatibility with the standard 8052. 4 ren receive enable: when set to 1 serial rec eption is enabled, otherwise reception is disabled. 3 tb8 this is the 9th bit to be transmitted in m odes 2 and 3. this bit is set and cleared by software as desired. 2 rb8 in modes 2 and 3 this is the received 9th dat a bit. in mode 1, if sm2 = 0, rb8 is the stop bit that was received. in mode 0 it has no function. 1 ti transmit interrupt flag: this flag is set by hardware at the end of the 8th bit time in mode 0, or at the beginning of the stop bit in all other modes during serial transmission. this bit must be cleared by software. 0 ri receive interrupt flag: this flag is set by hardware at the end of the 8th bit time in mode 0, or halfway through the stop bits time in the other modes during serial reception. however the restrictions of sm 2 apply to this bit. this bit can be cleared only by software. serial data buffer bit: 7 6 5 4 3 2 1 0 sbuf.7 sbuf.6 sbuf.5 sbuf.4 sbuf.3 sbuf.2 sbuf.1 sbuf.0 mnemonic: sbuf address: 99h
w79e201 publication release date: december 16, 2004 - 17 - revision a2 bit name function 7~0 sbuf serial data on the serial port is read from or written to this location. it actually consists of two separate inte rnal 8-bit registers. one is the receive resister, and the other is the transmit buffer. any read acce ss gets data from the receive data buffer, while write access is to the transmit data buffer. isp control register bit: 7 6 5 4 3 2 1 0 swrst/ reboot - ldap - - - fbootsl fprogen mnemonic: chpcon address: 9fh bit name function 7 swrst/ reboot set this bit to launch a whole device reset that is same as asserting high to rst pin, micro controller will be back to initial state and clear this bit automatically. to read this bit, its al ternate function to indicate the isp hardware reboot mode is invoking when reading it in high. 6 - reserved 5 ldap this bit is read only. high: device is executing the program in ld flash eprom low: device is executing the program in ap flash eprom. 4 - reserved 3 - reserved 2 - reserved 1 fbootsl loader program residence selection. set to high to route the device fetching code from ld flash eprom. 0 fprogen in system programming mode enable. set this bit to launch the isp mode. device will operate isp procedures, such as erase, program and read operations, according to correlative sfrs settings. during isp mode, device achieves isp operations by the way of idle state. in the other words, device is not indeed in idle mode is set bit pcon.1 while isp is enabled. clear this bit to disable isp mode, device get back to normal operation including idle state. port 2 bit: 7 6 5 4 3 2 1 0 p2.7 p2.6 p2.5 p2.4 p2.3 p2.2 p2.1 p2.0 mnemonic: p2 address: a0h p2.7-0: port 2 is a bi-directional i/o port with in ternal pull-ups. this port also provides the upper address bits for accesses to external memory.
w79e201 - 18 - port 4 bit: 7 6 5 4 3 2 1 0 - - - - - - - p4.0 mnemonic: p4 address: a5h p4.0: when b3 of security bits is set to logical 0, the p4.0 as reboot pin. when b3 of security bits is set to logical 1, the p4.0 as i/o pin. interrupt enable bit: 7 6 5 4 3 2 1 0 ea eadc et2 es et1 ex1 et0 ex0 mnemonic: ie address: a8h bit name function 7 ea global enable. enable/disable all interrupts. 6 eadc enable adc interrupt. 5 et2 enable timer 2 interrupt. 4 es enable serial port interrupt. 3 et1 enable timer 1 interrupt. 2 ex1 enable external interrupt 1. 1 et0 enable timer 0 interrupt. 0 ex0 enable external interrupt 0. slave address bit: 7 6 5 4 3 2 1 0 saddr.7 saddr.6 saddr.5 saddr.4 saddr.3 saddr.2 saddr.1 saddr.0 mnemonic: saddr address: a9h bit name function 7~0 saddr the saddr should be programmed to the given or broadcast address for serial port to which the slave processor is designated. isp address low byte bit: 7 6 5 4 3 2 1 0 sfral.7 sfral.6 sfral.5 sfral.4 sfral.3 sfral.2 sfral.1 sfral.0 mnemonic: sfral address: ach low byte destination address is for in system programming operations. sfrah and sfral address are specific rom bytes for eras ure, programming or read.
w79e201 publication release date: december 16, 2004 - 19 - revision a2 isp address high byte bit: 7 6 5 4 3 2 1 0 sfrah.7 sfrah.6 sfrah.5 sfrah.4 sfrah.3 sfrah.2 sfrah.1 sfrah.0 mnemonic: sfrah address: adh high byte destination address is for in system programming operations. sfrah and sfral address are specific rom bytes for eras ure, programming or read. isp data buffer bit: 7 6 5 4 3 2 1 0 sfrfd.7 sfrfd.6 sfrfd.5 sfrfd.4 sfrfd.3 sfrfd.2 sfrfd.1 sfrfd.0 mnemonic: sfrfd address: aeh in isp mode, read/write a specific byte ro m content must go through sfrfd register. isp operation modes bit: 7 6 5 4 3 2 1 0 - wfwin oen cen ctrl3 ctrl2 ctrl1 ctrl0 mnemonic: sfrcn address: afh bit name function 7 - reserve 6 wfwin on-chip flash eprom bank select for in-system programming. 0: 16k bytes flash eprom bank is sele cted as destination for re-programming. 1: 4k bytes flash eprom bank is sele cted as destination for re-programming. 5 oen flash eprom output is enabled. 4 cen flash eprom chip is enabled. 3~0 ctrl[3:0] the flash control signals isp mode wfwin noe nce ctrl<3:0> sfrah, sfral sfrfd erase 4kb ld flash prom 1 1 0 0010 x x erase 16k ap flash eprom 0 1 0 0010 x x program 4kb ld flash eprom 1 1 0 0001 address in data in program 16kbap flash eprom 0 1 0 0001 address in data in read 4kb ld flash eprom 1 0 0 0000 address in data out read 16kb ap flash eprom 0 0 0 0000 address in data out
w79e201 - 20 - port 3 bit: 7 6 5 4 3 2 1 0 p3.7 p3.6 p3.5 p3.4 p3.3 p3.2 p3.1 p3.0 mnemonic: p3 address: b0h p3.7-0: general purpose i/o port. each pin also has an alternate input or output function. there alternate functions are described below table. bit name function 7 p3.7 strobe for read from external ram 6 p3.6 wr strobe for write to external ram 5 p3.5 t1 timer/counter 1 external count input 4 p3.4 t0 timer/counter 0 external count input 3 p3.3 int1 external interrupt 1 2 p3.2 int0 external interrupt 0 1 p3.1 txd serial port 0 output 0 p3.0 rxd serial port 0 input interrupt priority bit: 7 6 5 4 3 2 1 0 - padc pt2 ps pt1 px1 pt0 px0 mnemonic: ip address: b8h bit name function 7 - this bit is un-implemented and will read high. 6 padc 1: to set interrupt priority of adc is highest priority level. 5 pt2 1: to set interrupt priority of timer 2 is highest priority level. 4 ps 1: to set interrupt priority of se rial port 0 is highest priority level. 3 pt1 1: to set interrupt priority of serial port 0 is highest priority level. 2 px1 1: to set interrupt priority of exte rnal interrupt 1 is highest priority level. 1 pt0 1: to set interrupt priority of timer 0 is highest priority level. 0 px0 1: to set interrupt priority of exte rnal interrupt 0 is highest priority level.
w79e201 publication release date: december 16, 2004 - 21 - revision a2 slave address mask enable bit: 7 6 5 4 3 2 1 0 saden.7 saden.6 saden.5 saden.4 saden.3 saden.2 saden.1 saden.0 mnemonic: saden address: b9h bit name function 7~0 saden this register enables the automatic addr ess recognition feature of the serial port 0. when a bit in the saden is set to 1, the same bit location in saddr will be compared with the incoming serial data. when saden is 0, then the bit becomes a "don't care" in the comparison. this register enables the automatic address recognition feature of the serial port 0. when all the bits of saden are 0, interrupt will occur for any incoming address. pwm 5 register bit: 7 6 5 4 3 2 1 0 pwm5.7 pwm5.6 pwm5.5 pwm5.4 pwm5.3 pwm5.2 pwm5.1 pwm5.0 mnemonic: pwm 5 address: c3h power management register bit: 7 6 5 4 3 2 1 0 - - - - - ale-off - - mnemonic: pmr address: c4h bit name function 7~3 - reserved. 2 ale-off this bit disables the expression of t he ale signal on the device pin during all on-board program and data memory accesses. external memory accesses will automatically enable ale independent of ale-off. 0: ale expression is enabled. 1: ale expression is disabled and keep in logic high state. 1~0 - reserved. status register bit: 7 6 5 4 3 2 1 0 - hip lip - - - spta0 spra0 mnemonic: status address: c5h
w79e201 - 22 - bit name function 7 - reserved. 6 hip high priority interrupt status. when set, it indicates that software is servicing a high priority interrupt. this bit will be cleared when the program executes the corresponding reti instruction. 5 lip low priority interrupt status. when set, it indicates that software is servicing a low priority interrupt. this bit will be cleared when the program executes the corresponding reti instruction. 4 - reserved. 3 - reserved. 2 - reserved. 1 spta0 serial port 0 transmit activity. this bi t is set during serial port is currently transmitting data. it is cleared when ti bit is set by hardware. 0 spra0 serial port 0 receive activity. this bi t is set during serial port is currently receiving a data. it is cleared when ri bit is set by hardware. timed access bit: 7 6 5 4 3 2 1 0 ta.7 ta.6 ta.5 ta.4 ta.3 ta.2 ta.1 ta.0 mnemonic: ta address: c7h ta: the timed access register cont rols the access to protected bits . to access protected bits, the user must first write aah to the ta. this must be immediately followed by a write of 55h to ta. now a window is opened in the protected bits for th ree machine cycles, during which the user can write to these bits. timer 2 control bit: 7 6 5 4 3 2 1 0 tf2 exf2 rclk tclk exen2 tr2 t2 c/ rl2 cp/ mnemonic: t2con address: c8h
w79e201 publication release date: december 16, 2004 - 23 - revision a2 bit name function 7 tf2 timer 2 overflow flag: this bit is set w hen timer 2 overflows. it is also set when the count is equal to the capture register in down count mode. it can be set only if rclk and tclk are both 0. it is cleared onl y by software. software can also set or clear this bit. 6 exf2 timer 2 external flag: a negative transit ion on the t2ex pin (p1.1) or timer 2 underflow/overflow will cause this fl ag to set based on the cp/rl2, exen2 and dcen bits. if set by a negative transition, this flag must be cleared by software. setting this bit in software or detecti on of a negative transition on t2ex pin will force a timer interrupt if enabled. 5 rclk receive clock flag: this bit determines the serial port time-base when receiving data in serial modes 1 or 3. if it is 0, then timer 1 overflow is used for baud rate generation, else timer 2 overflow is used. setting this bit forces timer 2 in baud rate generator mode. 4 tclk transmit clock flag: this bit determi nes the serial port time-base when transmitting data in mode 1 and 3. if it is set to 0, the timer 1 overflow is used to generate the baud rate clock, else timer 2 ov erflow is used. setting this bit forces timer 2 in baud rate generator mode. 3 exen2 timer 2 external enable: this bit enabl es the capture/reload function on the t2ex pin if timer 2 is not generating baud clocks for the serial port. if this bit is 0, then the t2ex pin will be ignored, else a negative transition detected on the t2ex pin will result in capture or reload. 2 tr2 timer 2 run control: this bit enables/disabl es the operation of timer 2.halting this will preserve the current count in th2, tl2. 1 t2 c/ counter/timer select: this bit determines whether timer 2 will function as a timer or a counter. independent of this bit, the timer will run at 2 clocks per tick when used in baud rate generator mode. if it is se t to 0, then timer 2 operates as a timer at a speed depending on t2m bit (ckcon.5), else, it will count negative edges on t2 pin. 0 rl2 cp/ capture/reload select: this bit determines whether the capture or reload function will be used for timer 2. if either rclk or tclk is set, this bit will not function and the timer will function in an auto-reload mode following each overflow. if the bit is 0 then auto-reload will occur when timer 2 overflows or a falling edge is detected on t2ex if exen2 = 1. if this bit is 1, then timer 2 captures will occur when a falling edge is detected on t2ex if exen2 = 1.
w79e201 - 24 - timed 2 mode control bit: 7 6 5 4 3 2 1 0 - - - - t2cr - - dcen mnemonic: t2mod address: c9h bit name function 7~4 - reserved. 3 t2cr timer 2 capture reset. in the timer 2 capture mode this bit enables/disables hardware automatically reset timer 2 while the value in tl2 and th2 have been transferred into the capture register. 2~1 - reserved. 0 dcen down count enable: this bit, in conjunc tion with the t2ex pin, controls the direction that timer 2 count s in 16-bit auto-reload mode. timer 2 capture lsb bit: 7 6 5 4 3 2 1 0 rcap2l.7 rcap2l.6 rcap2l.5 rcap2l.4 rcap2l.3 rcap2l.2 rcap2l.1 rcap2l.0 mnemonic: rcap2l address: cah rcap2l: this register is used to capture the tl2 value when a timer 2 is configured in capture mode. rcap2l is also used as the lsb of a 16-bit re load value when timer 2 is configured in auto- reload mode. timer 2 capture msb bit: 7 6 5 4 3 2 1 0 rcap2h.7 rcap2h.6 rcap2h.5 rcap2h.4 rcap2h.3 rcap2h.2 rcap2h.1 rcap2h.0 mnemonic: rcap2h address: cbh rcap2h: this register is used to capture the th 2 value when a timer 2 is configured in capture mode. rcap2h is also used as the msb of a 16-bit reload value when timer 2 is configured in auto-reload mode. timer 2 lsb bit: 7 6 5 4 3 2 1 0 tl2.7 tl2.6 tl2.5 tl2.4 tl2.3 tl2.2 tl2.1 tl2.0 mnemonic: tl2 address: cch tl2: timer 2 lsb
w79e201 publication release date: december 16, 2004 - 25 - revision a2 timer 2 msb bit: 7 6 5 4 3 2 1 0 th2.7 th2.6 th2.5 th2.4 th2.3 th2.2 th2.1 th2.0 mnemonic: th2 address: cdh th2: timer 2 msb pwm 4~5 control register 2 bit: 7 6 5 4 3 2 1 0 - - - - pwm5oe pwm4oe enpwm5 enpwm4 mnemonic: pwmcon2 address: ceh bit name function 7~4 - reserved. 3 pwm5oe output enable for pwm5 0: disable pwm5 output. 1: enable pwm5 output. 2 pwm4oe output enable for pwm4 0: disable pwm4 output. 1: enable pwm4 output. 1 enpwm5 enable pwm5 0: disable pwm5. 1: enable pwm5. 0 enpwm4 enable pwm4 0: disable pwm4. 1: enable pwm4. pwm 4 register bit: 7 6 5 4 3 2 1 0 pwm4.7 pwm4.6 pwm4.5 pwm4.4 pwm4.3 pwm4.2 pwm4.1 pwm4.0 mnemonic: pwm 4 address: cfh program status word bit: 7 6 5 4 3 2 1 0 cy ac f0 rs1 rs0 ov f1 p mnemonic: psw address: d0h
w79e201 - 26 - bit name function 7 cy carry flag: set for an arithmetic operati on which results in a carry being generated from the alu. it is also used as t he accumulator for the bit operations. 6 ac auxiliary carry: set when the previous oper ation resulted in a carry from the high order nibble. 5 f0 user flag 0: the general purpose flag t hat can be set or cleared by the user. 4 rs1 register bank select bits: 3 rs0 register bank select bits: 2 ov overflow flag: set when a carry was generat ed from the seventh bit but not from the 8th bit as a result of the pr evious operation, or vice-versa. 1 f1 user flag 1: the general purpose flag that can be set or cleared by the user by software. 0 p parity flag: set/cleared by hardware to indicate odd/even number of 1's in the accumulator. rs.1-0: register bank select bits: rs1 rs0 register bank address 0 0 0 00-07h 0 1 1 08-0fh 1 0 2 10-17h 1 1 3 18-1fh watchdog control bit: 7 6 5 4 3 2 1 0 - por - - wdif wtrf ewt rwt mnemonic: wdcon address: d8h bit name function 7 - reserved. 6 por power-on reset flag. hardware will set this flag on a power up condition. this flag can be read or written by software. a writ e by software is the only way to clear this bit once it is set. 5 - reserved. 4 - reserved. 3 wdif watchdog timer interrupt flag. if the wa tchdog interrupt is enabled, hardware will set this bit to indicate that the watchdog interrupt has occurred. if the interrupt is not enabled, then this bit indicates that t he time-out period has elapsed. this bit must be cleared by software. 2 wtrf watchdog timer reset flag. hardware will set this bit when the watchdog timer causes a reset. software can read it but mu st clear it manually. a power-fail reset will also clear the bit. this bit helps softw are in determining the cause of a reset. if ewt = 0, the watchdog timer will have no affect on this bit.
w79e201 publication release date: december 16, 2004 - 27 - revision a2 1 ewt enable watchdog timer reset. setting this bit will enable the watchdog timer reset function. 0 rwt reset watchdog timer. this bit helps in putting the watchdog timer into a know state. it also helps in resetting the watchdog timer before a time-out occurs. failing to set the ewt before time-out will cause an interrupt, if ewdi (eie.4) is set, and 512 clocks after that a watchdog timer reset will be generated if ewt is set. this bit is self-clearing by hardware. the wdcon sfr is set to a 0x0x0xx0b on an external reset. wtrf is set to a 1 on a watchdog timer reset, but to a 0 on power on/down resets. wtrf is not altered by an external reset. por is set to 1 by a power-on reset. ewt is set to 0 on a power-on reset and unaffected by other resets. all the bits in this sfr have unrestricted read access. por, ewt, wdif and rwt require timed access procedure to write. the remaining bits hav e unrestricted write accesses. please refer ta register description. ta eg c7h wdcon reg d8h ckcon reg 8eh mov ta, #aah mov ta, #55h setb wdcon.0 ; reset watchdog timer orl ckcon, #11000000b ; select 26 bits watchdog timer mov ta, #aah mov ta, #55h orl wdcon, #00000010b ; enable watchdog pwm prescale register bit: 7 6 5 4 3 2 1 0 pwmp.7 pwmp.6 pwmp.5 pwmp.4 pwmp.3 pwmp.2 pwmp.1 pwmp.0 mnemonic: pwmp address: d9h pwm 0 register bit: 7 6 5 4 3 2 1 0 pwm0.7 pwm0.6 pwm0.5 pwm0.4 pwm0.3 pwm0.2 pwm0.1 pwm0.0 mnemonic: pwm0 address: dah pwm 1 register bit: 7 6 5 4 3 2 1 0 pwm1.7 pwm1.6 pwm1.5 pwm1.4 pwm1.3 pwm1.2 pwm1.1 pwm1.0 mnemonic: pwm1 address: dbh
w79e201 - 28 - pwm 0~3 control register 1 bit: 7 6 5 4 3 2 1 0 pwm3oe pwm2oe enpwm3 enpwm2 pwm1oe pwm0oe enpwm1 enpwm0 mnemonic: pwmcon1 address: dch bit name function 7 pwm3oe output enable for pwm3 0: disable pwm3 output. 1: enable pwm3 output. 6 pwm2oe output enable for pwm2 0: disable pwm2 output. 1: enable pwm2 output. 5 enpwm3 enable pwm3 0: disable pwm3. 1: enable pwm3. 4 enpwm2 enable pwm2 0: disable pwm2. 1: enable pwm2. 3 pwm1oe output enable for pwm1 0: disable pwm1 output. 1: enable pwm1 output. 2 pwm0oe output enable for pwm0 0: disable pwm0 output. 1: enable pwm0 output. 1 enpwm1 enable pwm1 0: disable pwm1. 1: enable pwm1. 0 enpwm0 enable pwm0 0: disable pwm0. 1: enable pwm0. pwm 2 register bit: 7 6 5 4 3 2 1 0 pwm2.7 pwm2.6 pwm2.5 pwm2.4 pwm2.3 pwm2.2 pwm2.1 pwm2.0 mnemonic: pwm2 address: ddh pwm 3 register bit: 7 6 5 4 3 2 1 0 pwm3.7 pwm3.6 pwm3.5 pwm3.4 pwm3.3 pwm3.2 pwm3.1 pwm3.0 mnemonic: pwm3 address: deh
w79e201 publication release date: december 16, 2004 - 29 - revision a2 accumulator bit: 7 6 5 4 3 2 1 0 acc.7 acc.6 acc.5 acc.4 a cc.3 acc.2 acc.1 acc.0 mnemonic: acc address: e0h acc.7-0: the a (or acc) register is the standard 8052 accumulator. adc control register bit: 7 6 5 4 3 2 1 0 adc.1 adc.0 adcex adci adcs aadr2 aadr1 aadr0 mnemonic: adccon address: e1h bit name function 7 adc.1 bit 1 of adc result. 6 adc.0 bit 0 of adc result. 5 adcex enable external star t of conversion by stadc 0 = conversion can be started by software only (by setting adcs) 1 = conversion can be started by software or externally pin p2.0 (by a rising edge on stadc) 4 adci adc interrupt flag: this adci flag is set when an a/d conversion result is ready to be read. an interrupt is invoked if it is enabled. the flag may be cleared by the interrupt service routine. while this flag is set, the adc can not start a new conversion. adci can not set by software. 3 adcs adc start and status: setting this bi t starts an a/d conversion. it may be set by software or by the external stadc si gnal. the adc logic ensures that this signal is high while the adc is busy. on completion of the conversion, adcs is reset immediately after the interrupt flag has been set. adcs can not be reset by software. a new conversion may not be st arted while either adcs or adci is high. adci adcs adc status 0 0 1 1 0 1 0 1 adc not busy; a conversion can be started adc busy; start of a new conversion is blocked conversion completed; start of a new conversion requires adci=0 conversion completed; start of a new conversion requires adci=0 if adci is cleared by software while adcs is set at the same time, a new a/d conversion with the same channel number may be started. but it is recommended to reset adci before adcs is set. 2 aadr2 see the below table. 1 aadr1 see the below table. 0 aadr0 see the below table.
w79e201 - 30 - aadr2~aadr0: the adc analog input channel select bits: this binary coded address selects one of eight analogue port bits of adc input converte r. it can only be changed when adci and adcs are both low. aadr2 aadr1 aadr0 selected analog channel 0 0 0 adc0 0 0 1 adc1 0 1 0 adc2 0 1 1 adc3 1 0 0 adc4 1 0 1 adc5 1 1 0 adc6 1 1 1 adc7 adc conversion result register bit: 7 6 5 4 3 2 1 0 adc.9 adc.8 adc.7 adc.6 a dc.5 adc.4 adc.3 adc.2 mnemonic: adch address: e2h bit name function 7 adc.9 bit 9 of adc result. 6 adc.8 bit 8 of adc result. 5 adc.7 bit 7 of adc result. 4 adc.6 bit 6 of adc result. 3 adc.5 bit 5 of adc result. 2 adc.4 bit 4 of adc result. 1 adc.3 bit 3 of adc result. 0 adc.2 bit 2 of adc result. adc conversion enable register bit: 7 6 5 4 3 2 1 0 - - - - - - - nadcen mnemonic: adccen address: e4h nadcen: enable adc function: the def ault is ?1? that disables adc analog circuit. clear this bit to enable adc analog circuit.
w79e201 publication release date: december 16, 2004 - 31 - revision a2 extended interrupt enable bit: 7 6 5 4 3 2 1 0 - - - ewdi - - - - mnemonic: eie address: e8h bit name function 7~5 - reserved, will read high 4 ewdi enable watchdog timer interrupt 3~0 - reserved, will read high b register bit: 7 6 5 4 3 2 1 0 b.7 b.6 b.5 b.4 b.3 b.2 b.1 b.0 mnemonic: b address: f0h b.7-0: the b register is the standard 8052 regist er that serves as a second accumulator. extended interrupt priority bit: 7 6 5 4 3 2 1 0 - - - pwdi - - - - mnemonic: eip address: f8h bit name function 7~5 - reserved. 4 pwdi watchdog timer interrupt priority. 3~0 - reserved.
w79e201 - 32 - 8. instruction the w79e201 executes all the instructions of the standard 8032 family. the operation of these instructions, their effect on the fl ag bits and the status bits is exac tly the same. however, timing of these instructions is different. the reason for this is two fold. firstly, in the w79e201, each machine cycle consists of 4 clock periods, while in the st andard 8032 it consists of 12 clock periods. also, in the w79e201 there is only one fetch per machine cycl e i.e. 4 clocks per fetch, while in the standard 8032 there can be two fetches per machine cycle, which works out to 6 clocks per fetch. the advantage the w79e201 has is that since there is only one fetch per machine cycle, the number of machine cycles in most cases is equal to the number of operands that the instruction has. in case of jumps and calls there will be an additional cycle that will be needed to calculate the new address. but overall the w79e201 reduces the number of dummy fetches and wasted cycles, thereby improving efficiency as compared to the standard 8032. 8.1 instruction timing the instruction timing for the w79e201 is an important aspect, especially for those users who wish to use software instructions to generate timing delays. also , it provides the user with an insight into the timing differences between the w79e201 and t he standard 8032. in the w79e201 each machine cycle is four clock periods long. each clock peri od is designated a state. thus each machine cycle is made up of four states, c1, c2 c3 and c4, in that order. due to the reduced time for each instruction execution, both the clock edges are used for internal ti ming. hence it is important that the duty cycle of the clock be as close to 50% as possible to avoi d timing conflicts. as mentioned earlier, the w79e201 does one op-code fetch per machine cycle. therefore, in most of the instructions, the number of machine cycles needed to execute the in struction is equal to the number of bytes in the instruction. of the 256 available op-codes, 128 of them are single cy cle instructions. thus more than half of all op- codes in the w79e201 are executed in just four clo ck periods. most of the tw o-cycle instructions are those that have two byte instruction codes. howeve r there are some instructions that have only one byte instructions, yet they are tw o cycle instructions. one instructi on which is of importance is the movx instruction. in the standard 8032, the movx inst ruction is always two machine cycles long. however in the w79e201, the user has a facility to stretch the duration of this instruction from 2 machine cycles to 9 machine cycles. the rd and wr strobe lines are also proportionately elongated. this gives the user flexibility in accessi ng both fast and slow peripher als without the use of external circuitry and with minimum software overhead. the rest of the instruct ions are either three, four or five machine cycle instructions. note that in the w79e201, based on the number of machine cycles, there are five different types, while in t he standard 8032 there are only three. however, in the w79e201 each machine cycle is made of only 4 clo ck periods compared to the 12 clock periods for the standard 8032. therefore, even though the number of categories has increased, each instruction is at least 1.5 to 3 times faster than the standard 8032 in terms of clock periods.
w79e201 publication release date: december 16, 2004 - 33 - revision a2 single cycle c4 c3 c2 c1 clk ale psen ad7-0 port 2 a7-0 address a15-8 data_ in d7-0 single cycle instruction timing instruction fetch c4 c3 c2 c1 op-code address a15-8 address a15-8 ale psen pc ad7-0 port 2 clk operand fetch c4 c3 c2 c1 operand pc+1 two cycle instruction timing
w79e201 - 34 - operand operand a7-0 a7-0 a7-0 op-code address a15-8 address a15-8 address a15-8 operand fetch operand fetch instruction fetch c2 c3 c4 c2 c3 c4 c4 c3 c2 c1 c1 c1 clk ale psen ad7-0 port 2 three cycle instruction timing operand operand operand op-code address a15-8 address a15-8 address a15-8 address a15-8 a7-0 a7-0 a7-0 a7-0 operand fetch operand fetch operand fetch instruction fetch c2 c1 c4 c3 c2 c1 clk ale psen ad7-0 port 2 c4 c3 c2 c1 c4 c3 c2 c1 c4 c3 four cycle instruction timing
w79e201 publication release date: december 16, 2004 - 35 - revision a2 operand operand operand op-code address a15-8 address a15-8 address a15-8 address a15-8 a7-0 a7-0 a7-0 a7-0 operand fetch operand fetch operand fetch operand fetch instruction fetch c2 c1 c4 c3 c2 c1 clk ale psen ad7-0 port 2 c4 c3 c2 c1 c4 c3 c2 c1 c4 c3 c2 c1 c4 c3 operand a7-0 address a15-8 five cycle instruction timing 8.1.1 external data memory access timing the timing for the movx instruction is another f eature of the w79e201. in the standard 8032, the movx instruction has a fixed execution time of 2 machine cycles. however in the w79e201, the duration of the access can be varied by the user. the instruction starts off as a normal op-code fetc h of 4 clocks. in the next machine cycle, the w79e201 puts out the address of the external data memory and the ac tual access occurs here. the user can change the duration of this access time by setting the stretch value. the clock control sfr (ckcon) has three bits that control the stretc h value. these three bits are m2-0 (bits 2-0 of ckcon). these three bits give the user 8 differ ent access time options. the stretch can be varied from 0 to 7, resulting in movx instructions that last from 2 to 9 machine cycles in length. note that the stretching of the instruction only resu lts in the elongation of the movx inst ruction, as if the state of the cpu was held for the desired period. there is no effe ct on any other instruct ion or its timing. by default, the stretch value is set at 1, giving a movx instruction of 3 machine cycles. if desired by the user the stretch value can be set to 0 to give t he fastest movx instruction of only 2 machine cycles.
w79e201 - 36 - table 4. data memory cycle stretch values m2 m1 m0 machine cycles rd or wr strobe width in clocks rd or wr strobe width @ 25 mhz rd or wr strobe width @ 40 mhz 0 0 0 2 2 80 ns 50 ns 0 0 1 3 (default) 4 160 ns 100 ns 0 1 0 4 8 320 ns 200 ns 0 1 1 5 12 480 ns 300 ns 1 0 0 6 16 640 ns 400 ns 1 0 1 7 20 800 ns 500 ns 1 1 0 8 24 960 ns 600 ns 1 1 1 9 28 1120 ns 700 ns next instruction machine cycle second machine cycle first machine cycle last cycle of previous instruction c4 port 2 port 0 wr psen ale clk c3 c2 d0-d7 a0-a7 d0-d7 a0-a7 d0-d7 a0-a7 d0-d7 a15-a8 a15-a8 a15-a8 a15-a8 a0-a7 c1 c4 c3 c2 c1 c4 c3 c2 c1 c4 c3 c2 c1 movx instruction cycle next inst. read next inst. address movx data out movx data address movx inst. address movx inst . data memory write with stretch value = 0
w79e201 publication release date: december 16, 2004 - 37 - revision a2 next instruction machine cycle third machine cycle second machine cycle first machine cycle last cycle of previous instruction c4 port 2 port 0 wr psen ale clk c3 c2 d0-d7 a0-a7 d0-d7 a0-a7 d0-d7 a0-a7 d0-d7 a15-a8 a15-a8 a15-a8 a15-a8 a0-a7 c1 c4 c3 c2 c1 c4 c3 c2 c1 c4 c3 c2 c1 movx instruction cycle next inst. read next inst. address movx data out movx data address movx inst. address movx inst. c4 c3 c2 c1 data memory write with stretch value = 1 next instruction machine cycle fourth machine cycle third machine cycle second machine cycle first machine cycle last cycle of previous instruction c4 port 2 port 0 wr psen ale clk c3 c2 d0-d7 a0-a7 d0-d7 a0-a7 d0-d7 a0-a7 d0-d7 a15-a8 a15-a8 a15-a8 a15-a8 a0-a7 c1 c4 c3 c2 c1 c4 c3 c2 c1 c4 c3 c2 c1 movx instruction cycle next inst. read next inst. address movx data out movx data address movx inst. address movx inst. c4 c3 c2 c1 c4 c3 c2 c1 data memory write with stretch value = 2
w79e201 - 38 - 9. power management the w79e201 has several features that help the user to control the power cons umption of the device. the power saving features is basically the po wer down mode and the idle mode of operation. idle mode the user can put the device into idle mode by writing 1 to the bit pcon.0. the instruction that sets the idle bit is the last instruction that will be execut ed before the device goes into idle mode. in the idle mode, the clock to the cpu is hal ted, but not to the interrupt, timer, watchdog timer and serial port blocks. this forces the cpu state to be frozen; t he program counter, the stack pointer, the program status word, the accumulator and the other regist ers hold their contents. the ale and psen pins are held high during the idle state. the port pins hold t he logical states they had at the time idle was activated. the idle mode can be terminated in two wa ys. since the interrupt c ontroller is still active, the activation of any enabled interrupt can wake up the processor. this will automatically clear the idle bit, terminate the idle mode, and the interrupt serv ice routine (isr) will be ex ecuted. after the isr, execution of the program will continue from the in struction which put the device into idle mode. the idle mode can also be exited by activating the reset. the device can be put into reset either by applying a high on the external rst pin, a power on reset condition or a watchdog timer reset. the external reset pin has to be held high for at leas t two machine cycles i.e. 8 clock periods to be recognized as a valid reset. in the reset conditi on the program counter is reset to 0000h and all the sfrs are set to the reset condition. since the clo ck is already running there is no delay and execution starts immediately. in the idle mode, the watchdog timer continues to run, and if enabled, a time-out will cause a watchdog timer interrupt which will wa ke up the device. the software must reset the watchdog timer in order to preempt the reset which will occur after 512 clock periods of the time-out. when the w79e201 is exiting from an idle mode with a reset, the instruction following the one which put the device into idle mode is not execut ed. so there is no danger of unexpected writes. power down mode the device can be put into power down mode by writ ing 1 to bit pcon.1. the instruction that does this will be the last instruction to be executed bef ore the device goes into power down mode. in the power down mode, all the clocks are stopped and the devic e comes to a halt. all activity is completely stopped and the power consumption is reduced to the lo west possible value. in this state the ale and psen pins are pulled low. the port pins output the values held by their respective sfrs. the w79e201 will exit the power down mode with a reset or by an external interrupt pin enabled as level detect. an external reset can be used to exit the power down stat e. the high on rst pin terminates the power down mode, and restarts the clock. the program execution will restart from 0000h. in the power down mode, the clock is stopped, so the watchdog timer cannot be used to provide the reset to exit power down mode. the w79e201 can be woken from the power down mode by forcing an external interrupt pin activated, provided the corresponding interrupt is enabled, while the global enable(ea) bit is set and the external input has been set to a level detect m ode. if these conditions are met, then the low level on the external pin re-starts the oscillator. then dev ice executes the interrupt service routine for the corresponding external interrupt. after the interrupt service routine is completed, the program execution returns to the instruction after the one which put the device into power down mode and continues from there.
w79e201 publication release date: december 16, 2004 - 39 - revision a2 table 5. status of external pins during idle and power down mode program memory ale psen port0 port1 port2 port3 idle internal 1 1 data data data data idle external 1 1 float data address data power down internal 0 0 data data data data power down external 0 0 float data data data reset conditions the user has several hardware related options fo r placing the w79e201 into reset condition. in general, most register bits go to their reset value irre spective of the reset condition, but there are a few flags whose state depends on the source of reset. the user can use these flags to determine the cause of reset using software. there are two ways of putting the device into reset state. they are external reset and watchdog reset. external reset the device continuously samples the rst pin at state c4 of every ma chine cycle. therefore the rst pin must be held for at least 2 machine cycles to ensure detection of a valid rst high. the reset circuitry then synchronously applies the internal reset signal. thus the reset is a synchronous operation and requires the clock to be running to cause an external reset. once the device is in reset condition, it will rema in so as long as rst is 1. even after rst is deactivated, the device will continue to be in rese t state for up to two machine cycles, and then begin program execution from 0000h. there is no flag associ ated with the external reset condition. however since the other two reset sources have flags, the ex ternal reset can be considered as the default reset if those two flags are cleared. the software must clear the por flag after reading i t, otherwise it will not be possible to correctly determine future reset sources. if the power fails, i.e. falls below vrst, then the device will once again go into reset state. when the power returns to the proper operating levels, the device will again perform a power on reset delay and set the por flag. watchdog timer reset the watchdog timer is a free running timer with progra mmable time-out intervals. the user can clear the watchdog timer at any time, causing it to restar t the count. when the time-out interval is reached an interrupt flag is set. if the watchdog reset is enabled and the watchdog timer is not cleared, then 512 clocks from the flag being set, the watchdog time r will generate a reset. this places the device into the reset condition. the reset condition is ma intained by hardware for two machine cycles. once the reset is removed the devic e will begin execution from 0000h. reset state most of the sfrs and registers on the device will go to the same condition in the reset state. the program counter is forced to 0000h and is held ther e as long as the reset condition is applied. however, the reset state does not affect the on- chip ram. the data in the ram will be preserved during the reset. however, the stack pointer is re set to 07h, and therefore the stack contents will be lost. the ram contents will be lost if the v dd falls below approximately 2v, as this is the minimum voltage level required for the ram to operate normally. therefore after a first time power on reset the
w79e201 - 40 - ram contents will be indeterminate. during a power fa il condition, if the power falls below 2v, the ram contents are lost. after a reset most sfrs are cleared. interrupt s and timers are disabled. the watchdog timer is disabled if the reset source was a por. the ports sfrs have ffh written into them which puts the port pins in a high state. port 0 float s as it does not have on-chip pull-ups. table 6. sfr reset value sfr name reset value sfr name reset value p0 11111111b eip xxx00000b sp 00000111b ip x0000000b dpl 00000000b saden 00000000b dph 00000000b pmr xxxxx0xxb pcon 00xx0000b statut2 000x0000b tcon 00000000b t2con 00000000b tmod 00000000b t2mod 00000x00b tl0 00000000b rcap2l 00000000b tl1 00000000b rcap2h 00000000b th0 00000000b tl2 00000000b th1 00000000b th2 00000000b ckcon 00000001b psw 00000000b p1 11111111b wdcon 0x0x0xx0b scon 00000000b pwmp 00000000b sbuf xxxxxxxxb pw mcon1 00000000b p2 11111111b pwm0 00000000b p0r 00000000b pwm1 00000000b p4 xxxxxxx1b pwm2 00000000b ie 00000000b pwm3 00000000b saddr 00000000b acc 00000000b chpcon 00000000b adccon xxxxx000b sfral 00000000b adch xxxxxxxxb sfrah 00000000b a dccen xxxxxxx1b sfrfd 11111111b pwmcon2 00000000b sfrcn 00111111b pwm4 00000000b p3 11111111b eie xxx00000b pwm5 00000000b b 00000000b the wdcon sfr bits are set/cleared in reset condition depending on the source of the reset. external reset watchdog reset power on reset wdcon 0x0x0xx0b 0x0x01x0b 01000000b the por bit wdcon.6 is set only by the power on reset. the wtrf bit wdcon.2 is set when the watchdog timer causes a reset. a power on reset will also clear this bit. the ewt bit wdcon.1 is
w79e201 publication release date: december 16, 2004 - 41 - revision a2 cleared by power on resets. this disables the wa tchdog timer resets. a watchdog or external reset does not affect the ewt bit. 10. interrupts the w79e201 has a two priority level interrupt structur e with 8 interrupt sources. each of the interrupt sources has an individual priority bit, flag, interrupt vector and enable bit. in addition, the interrupts can be globally enabled or disabled. interrupt sources the external interrupts int0 and int1 can be either edge triggered or level triggered, depending on bits it0 and it1. the bits ie0 and ie1 in the tcon register are the flags which are checked to generate the interrupt. in the edge triggered mode, t he intx inputs are sampled in every machine cycle. if the sample is high in one cycle and low in the next, then a high to low transition is detected and the interrupts request flag iex in tcon is se t. the flag bit requests the interrupt. since the external interrupts are sampled every machine cycle, they have to be held high or low for at least one complete machine cycle. the iex flag is automatica lly cleared when the service routine is called. if the level triggered mode is selected, then the requesting sour ce has to hold the pin low till the interrupt is serviced. the iex flag will not be cleared by the hardware on entering the service routine. if the interrupt continues to be held low even after the serv ice routine is completed, then the processor may acknowledge another interrupt reques t from the same source. the timer 0 and 1 interrupts are generated by the tf0 and tf1 flags. these flags are set by the overflow in the timer 0 and timer 1. the tf0 and tf1 flags are automatically cleared by the hardware when the timer interrupt is serviced. the timer 2 interrupt is generated by a logical or of the tf2 and the exf2 flags. these flags are set by ov erflow or capture/reload events in the timer 2 operation. the hardware does not clear these flags w hen a timer 2 interrupt is executed. software has to resolve the cause of the interrupt bet ween tf2 and exf2 and clear the appropriate flag. the watchdog timer can be used as a system monitor or a simple timer. in either case, when the time-out count is reached, the watchdog timer interrupt flag wdif (wdcon.3) is set. if the interrupt is enabled by the enable bit eie.4, then an interrupt will occur. all the bits that generate interrupts can be set or reset by hardware, and thereby software initiated interrupts can be generated. each of the individual interrupts can be enabled or disabled by setting or clearing a bit in the ie sfr. ie also has a global enable/disable bit ea, which can be cleared to disable all the interrupts. priority level structure there are two priority levels for the interrupts, highest, high and low. the interrupt sources can be individually set to either high or low levels. natu rally, a higher priority interrupt cannot be interrupted by a lower priority interrupt. however there ex ists a pre-defined hierarchy amongst the interrupts themselves. this hierarchy comes into play when the interrupt controller has to resolve simultaneous requests having the same priority level. this hier archy is defined as shown below; the interrupts are numbered starting from the highest priority to the lowest.
w79e201 - 42 - table 7. priority structure of interrupts source flag vector address priority level external interrupt 0 ie0 0003h 1(highest) adc interrupt adci 006bh 2 timer 0 overflow tf0 000bh 3 external interrupt 1 ie1 0013h 4 timer 1 overflow tf1 001bh 5 serial port ri + ti 0023h 6 timer 2 overflow tf2 + exf2 002bh 7 watchdog timer wdif 0063h 8 (lowest) 11. programmable timers/counters the w79e201 has three 16-bit programmable time r/counters and one programmable watchdog timer. the watchdog timer is operationally quite different from the other two timers. 11.1 timer/counters 0 & 1 the timer/counters 0/1 have two 16-bit timer/counter s. each of these timer/counters has two 8 bit registers which form the 16 bit counting register. fo r timer/counter 0 they are th0, the upper 8 bits register, and tl0, the lower 8 bit register. similarl y timer/counter 1 has two 8 bit registers, th1 and tl1. the two can be configured to operate either as timers, counting machine cycles or as counters counting external inputs. when configured as a "timer", the timer counts cl ock cycles. the timer clock can be programmed to be thought of as 1/12 of t he system clock or 1/4 of the system clock. in the "counter" mode, the register is incremented on the falling edge of the external input pin, t0 in case of timer 0, and t1 for timer 1. the t0 and t1 inputs are sampled in every machine cycle at c4. if the sampled value is high in one machine cycle and low in the next, then a valid high to low transition on the pin is recognized and the count register is incremented. since it takes two machine cycles to recognize a negative transition on the pin, the maximum rate at which c ounting will take place is 1/24 of the master clock frequency. in either the "timer" or "counter" mode, the count register will be updated at c3. therefore, in the "timer" mode, the recognized negative transition on pin t0 and t1 can cause the count register value to be updated only in the ma chine cycle following the one in which the negative edge was detected. the "timer" or "counter" function is selected by the " t c/ " bit in the tmod special function register. each timer/counter has one selection bit for its own; bit 2 of tmod selects the function for timer/counter 0 and bit 6 of tmod selects the function for timer/counter 1. in addition each timer/counter can be set to operate in any one of four possible modes. the mode selection is done by bits m0 and m1 in the tmod sfr. time-base selection the w79e201 gives the user two modes of operation for the timer. the timers can be programmed to operate like the standard 8051 family, c ounting at the rate of 1/12 of the clock speed. this will ensure that timing loops on the w79e201 and the standard 8051 can be matched. this is the default mode of operation of the w79e201 timers. the user also has the option to count in the turbo mode, where the
w79e201 publication release date: december 16, 2004 - 43 - revision a2 timers will increment at the rate of 1/4 clock speed. this will straight-away increase the counting speed three times. this selection is done by the t0 m and t1m bits in ckcon sfr. a reset sets these bits to 0, and the timers then oper ate in the standard 8051 mode. the user should set these bits to 1 if the timers are to operate in turbo mode. mode 0 in mode 0, the timer/counters act as a 8 bit counter with a 5 bit, divide by 32 pre-scale. in this mode we have a 13 bit timer/counter. the 13 bit counter cons ists of 8 bits of thx and 5 lower bits of tlx. the upper 3 bits of tlx are ignored. the negative edge of the clock is incr ements the count in the tlx register. when the fifth bit in tlx moves from 1 to 0, then the count in the thx r egister is incremented. when the count in thx is moving from ffh to 00h, then the overflow flag tfx in tcon sfr is set. the counted input is enabled only if trx is set and either gate = 0 or intx = 1. when t c/ is set to 0, then it will count clock cycles, and if t c/ is set to 1, then it will count 1 to 0 trans itions on t0 (p3.4) for timer 0 and t1 (p3.5) for timer 1. when the 13 bit count reaches 1fffh the next count will cause it to roll-over to 0000h. the timer overflow flag tfx of the relevant timer is set and if enabled an interrupts will occur. note that when used as a timer, the time-base may be either cl ock cycles/12 or clock cy cles/4 as selected by the bits txm of the ckcon sfr. 1/4 1/12 c/t = tmod.2 (c/t = tmod.6) t0m = ckcon.3 (t1m = ckcon.4) m1,m0 = tmod.1,tmod.0 (m1,m0 = tmod.5,tmod.4) interrupt t0 = p3.4 (t1 = p3.5) th0 (th1) tl0 (tl1) tf0 (tf1) tr0 = tcon.4 (tr1 = tcon.6) gate = tmod.3 (gate = tmod.7) int0 = p3.2 (int1 = p3.3) 7 0 tfx 4 7 0 timer 1 functions are shown in brackets 1 00 0 0 1 01 osc timer/counter mode 0 & mode 1
w79e201 - 44 - mode 1 mode 1 is similar to mode 0 except that the counting register form s a 16 bit counter, rather than a 13 bit counter. this means that all the bits of th x and tlx are used. roll-over occurs when the timer moves from a count of ffffh to 0000h. the timer overfl ow flag tfx of the relevant timer is set and if enabled an interrupt will occur. the selection of the ti me-base in the timer mode is similar to that in mode 0. the gate function operates similarly to that in mode 0. mode 2 in mode 2, the timer/counter is in the auto rel oad mode. in this mode, tlx acts as a 8 bit count register, while thx holds the reload value. when the tlx register overflows from ffh to 00h, the tfx bit in tcon is set and tlx is reloaded with the c ontents of thx, and the c ounting process continues from here. the reload operation leaves the cont ents of the thx register unchanged. counting is enabled by the trx bit and proper setting of gate and intx pins. as in the other two modes 0 and 1 mode 2 allows counting of either clock cycles (clock/12 or clock/4) or pulses on pin tn. 1/4 1/12 t0m = ckcon.3 (t1m = ckcon.4) c/t = tmod.2 (c/t = tmod.6) interrupt t0 = p3.4 (t1 = p3.5) th0 (th1) tl0 (tl1) tf0 (tf1) tr0 = tcon.4 (tr1 = tcon.6) gate = tmod.3 (gate = tmod.7) int0 = p3.2 (int1 = p3.3) 7 0 tfx 7 0 timer 1 functions are shown in brackets 1 0 0 1 osc timer/counter mode 2 mode 3 mode 3 has different operating methods for the two ti mer/counters. for timer/c ounter 1, mode 3 simply freezes the counter. timer/counter 0, however, configures tl0 and th0 as two separate 8 bit count registers in this mode. the logic for this mode is shown in the figure. tl0 uses the timer/counter 0 control bits t c/ , gate, tr0, int0 and tf0. the tl0 can be used to count clock cycles (clock/12 or clock/4) or 1-to-0 transitions on pin t0 as determined by t c/ (tmod.2). th0 is forced as a clock cycle counter (clock/12 or clock/ 4) and takes over the use of tr 1 and tf1 from timer/counter 1. mode 3 is used in cases where an extra 8 bit timer is needed. with timer 0 in mode 3, timer 1 can still be used in modes 0, 1 and 2., but its flexibility is somewhat limited. while its basic functionality is maintained, it no longer has control over its over flow flag tf1 and the enable bit tr1. timer 1 can still be used as a timer/counter and retains the use of gate and int1 pin. in this condition it can be turned on and off by switching it out of and into its own mode 3. it can also be used as a baud rate generator for the serial port.
w79e201 publication release date: december 16, 2004 - 45 - revision a2 1/4 1/12 t0m = ckcon.3 interrupt c/t = tmod.2 t0 = p3.4 th0 tl0 tr0 = tcon.4 gate = tmod.3 tr1 = tcon.6 int0 = p3.2 7 0 tf1 7 0 interrupt tf0 1 0 0 1 osc timer/counter 0 mode 3 11.2 timer/counter 2 timer/counter 2 is a 16 bit up/down counter which is configured by the t2mo d register and controlled by the t2con register. timer/counter 2 is equipped with a capture/reload capability. as with the timer 0 and timer 1 counters, there exists consi derable flexibility in selecting and controlling the clock, and in defining the operating mode. the clo ck source for timer/counter 2 may be selected for either the external t2 pin ( t2 c/ = 1) or the crystal oscillator, which is divided by 12 or 4 ( t2 c/ = 0). the clock is then enabled when tr2 is a 1, and disabled when tr2 is a 0. capture mode the capture mode is enabled by setting the rl2 cp/ bit in the t2con register to a 1. in the capture mode, timer/counter 2 serves as a 16 bit up count er. when the counter rolls over from ffffh to 0000h, the tf2 bit is set, which will generate an in terrupt request. if the exen2 bit is set, then a negative transition of t2ex pin will cause the value in the tl2 and th2 register to be captured by the rcap2l and rcap2h registers. this action also caus es the exf2 bit in t2con to be set, which will also generate an interrupt. setting the t2cr bit (t2m od.3), the w79e201 allows hardware to reset timer 2 automatically after the va lue of tl2 and th2 have been captured.
w79e201 - 46 - rclk+tclk=0, rl2 cp/ =t2con.0=1 1/4 1/12 t2m = ckcon.5 c/t2 = t2con.1 t2con.7 t2 = p1.0 t2con.6 tr2 = t2con.2 t2ex = p1.1 exen2 = t2con.3 exf2 timer 2 interrupt tf2 th2 tl2 rcap2h rcap2l 1 0 0 1 osc 16-bit capture mode auto-reload mode, counting up the auto-reload mode as an up counter is enabled by clearing the rl2 cp/ bit in the t2con register and clearing the dcen bit in t2mod register. in th is mode, timer/counter 2 is a 16 bit up counter. when the counter rolls over from ffffh, a reload is generated that causes the contents of the rcap2l and rcap2h registers to be reloaded into the tl2 and th2 registers. the reload action also sets the tf2 bit. if the exen2 bit is set, then a negative transition of t2ex pin will also cause a reload. this action also sets the exf2 bit in t2con. rclk+tclk=0, rl2 cp/ =t2con.0=0, dcen=0 1/4 1/12 t2m = ckcon.5 c/t2 = t2con.1 t2con.7 t2 = p1.0 t2con.6 tr2 = t2con.2 t2ex = p1.1 exen2 = t2con.3 exf2 timer 2 interrupt tf2 th2 tl2 rcap2 h rcap2l 1 0 0 1 osc 16-bit auto-reload mode, counting up
w79e201 publication release date: december 16, 2004 - 47 - revision a2 auto-reload mode, counting up/down timer/counter 2 will be in auto-re load mode as an up/down counter if rl2 cp/ bit in t2con is cleared and the dcen bit in t2mod is set. in this mode, timer/counter 2 is an up/down counter whose direction is controlled by the t2ex pin. a 1 on this pin cause the counter to count up. an overflow while counting up will cause the counter to be reloaded with the contents of the capture registers. the next down count following the case where the content s of timer/counter equal the capture registers will load an ffffh into timer/counter 2. in either ev ent a reload will set the tf2 bit. a reload will also toggle the exf2 bit. however, the exf2 bit can not generate an interrupt while in this mode. rclk+tclk=0, rl2 cp/ =t2con.0=0, dcen=1 c/t = t2con.1 1/4 1/12 t2m = ckcon.5 down counting reload value t2con.7 up counting reload value t2 = p1.0 t2con.6 tr2 = t2con.2 t2ex = p1.1 exf2 timer 2 interrupt tf2 th2 tl2 rcap2h rcap2l 1 0 0 1 0ffh 0ffh osc 16-bit auto-reload up/down counter baud rate generator mode the baud rate generator mode is enabled by setting either the rclk or tclk bits in t2con register. while in the baud rate generator mode, timer/counter 2 is a 16 bit counter with auto reload when the count rolls over from ffffh. however, rolling-over does not set the tf2 bit. if exen2 bit is set, then a negative transition of the t2ex pin will set exf2 bi t in the t2con register and cause an interrupt request. rclk+tclk=0 c/t = t2con.1 t2 = p1.0 t2con.6 tr2 = t2con.2 t2ex = p1.1 exen2 = t2con.3 exf2 timer 2 overflow timer 2 interrupt th2 tl2 rcap2h rcap2l 0 1 osc baud rate generator mode
w79e201 - 48 - 12. watchdog timer the watchdog timer is a free-running timer which c an be programmed by the user to serve as a system monitor, a time-base generator or an event timer. it is basically a set of dividers that divide the system clock. the divider output is selectable and determines the time -out interval. when the time-out occurs a flag is set, which can cause an interrupt if enabled, and a system reset can also be caused if it is enabled. the interrupt will occur if the i ndividual interrupt enable and the global enable are set. the interrupt and reset functions are independent of each other and may be used separately or together depending on the user?s software. 16 wd1,wd0 00 01 10 11 interrupt reset enable watchdog timer reset ewt(wdcon.1) reset watchdog rwt(wdcon.0) 0 17 19 20 22 23 25 time-out wdif wtrf 512 clock delay ewdi(eie.4) xt watchdog timer the watchdog timer should first be restarted by using rw t. this ensures that the timer starts from a known state. the rwt bit is used to restart the watc hdog timer. this bit is self clearing, i.e. after writing a 1 to this bit the software will automatica lly clear it. the watchdog timer will now count clock cycles. the time-out interval is selected by the two bits wd1 and wd0 (ckcon.7 and ckcon.6). when the selected time-out occurs, the watchdog in terrupt flag wdif (wdcon.3) is set. after the time-out has occurred, the watchdog timer wait s for an additional 512 clock cycles. if the watchdog reset ewt (wdcon.1) is enabled, then 512 clocks after the time-out, if there is no rwt, a system reset due to watchdog timer will occur. this will last for two machine cycles, and the watchdog timer reset flag wtrf (wdcon.2) will be set. this indi cates to the software that the watchdog was the cause of the reset. when used as a simple timer, the reset and interrupt functions are disabled. the timer will set the wdif flag each time the timer completes the selected time interval. the wdif flag is polled to detect a time-out and the rwt allows software to restart the timer. the watchdog timer can also be used as a very long timer. the interrupt feature is enabled in this case. every time the time-out occurs an interrupt will occur if the global interrupt enable ea is set. the main use of the watchdog timer is as a system monitor. this is important in real-time control applications. in case of some power glitches or electro-magnetic interference, the processor may begin to execute errant code. if this is left unc hecked the entire system may crash. using the watchdog timer interrupt during software development will allow the user to select ideal watchdog reset locations. the code is first written without the watchdog interrupt or reset. then the watchdog interrupt is enabled to identify code locations wher e interrupt occurs. the user can now insert instructions to reset the watchdog timer which w ill allow the code to run without any watchdog timer interrupts. now the watchdog timer reset is enabled and the watchdog interrupt may be disabled. if
w79e201 publication release date: december 16, 2004 - 49 - revision a2 any errant code is executed now, then the reset wa tchdog timer instructions will not be executed at the required instants and watchdog reset will occur. the watchdog time-out selection will result in di fferent time-out values depending on the clock speed. the reset, when enabled, it will occur 512 clocks after the time-out had occurred. table 9. time-out values for the watchdog timer wd1 wd0 watchdog interval number of clocks time @ 1.8432 mhz time @ 10 mhz time @ 25 mhz 0 0 2 17 131072 71.11 ms 13.11 ms 5.24 ms 0 1 2 20 1048576 568.89 ms 104.86 ms 41.94 ms 1 0 2 23 8388608 4551.11 ms 838.86 ms 335.54 ms 1 1 2 26 67108864 36408.88 ms 6710.89 ms 2684.35 ms the watchdog timer will de disabled by a power-on/fail reset. the watchdog timer reset does not disable the watchdog timer, but will restart it. in general , software should restart the timer to put it into a known state. the control bits that support the watchdog timer are discussed below. watchdog control bit name function 7 - reserved. 6 por power-on reset flag. hardware will set this flag on a power up condition. this flag can be read or written by software. a writ e by software is the only way to clear this bit once it is set. 5 - reserved. 4 - reserved. 3 wdif watchdog timer interrupt flag. if the wa tchdog interrupt is enabled, hardware will set this bit to indicate that the watchdog interrupt has occurred. if the interrupt is not enabled, then this bit indicates that t he time-out period has elapsed. this bit must be cleared by software. 2 wtrf watchdog timer reset flag. hardware will set this bit when the watchdog timer causes a reset. software can read it but mu st clear it manually. a power-fail reset will also clear the bit. this bit helps softw are in determining the cause of a reset. if ewt = 0, the watchdog timer will have no affect on this bit. 1 ewt enable watchdog timer reset. setting this bit will enable the watchdog timer reset function. 0 rwt reset watchdog timer. this bit helps in putting the watchdog timer into a know state. it also helps in resetting the watchdog timer before a time-out occurs. failing to set the ewt before time-out will cause an interrupt, if ewdi (eie.4) is set, and 512 clocks after that a watchdog timer reset will be generated if ewt is set. this bit is self-clearing by hardware.
w79e201 - 50 - clock control wd1, wd0: ckcon.7, ck con.6 - watchdog timer mode select bits. these two bits select the time- out interval for the watchdog timer. the rese t time is 512 clocks longer than the interrupt time-out value. the default watchdog time-out is 2 17 clocks, which is the shortest time-out period. the ewt, wdif and rwt bits are protected by the timed access pr ocedure. this prevents software from accidentally enabling or disabling the watchdog timer. more import antly, it makes it highly improbable that errant code can enable or disable the watchdog timer. please refer as below demo program. org 63h mov ta,#aah mov ta,#55h clr wdif jnb execute_reset_flag, bypass_reset ; test if cpu need to reset. jmp $ ; wait to reset bypass_reset: mov ta,#aah mov ta,#55h setb rwt reti org 300h start: mov ckcon,#01h ; select 2 ^ 17 timer ; mov ckcon,#61h ; select 2 ^ 20 timer ; mov ckcon,#81h ; select 2 ^ 23 timer ; mov ckcon,#c1h ; select 2 ^ 26 timer mov ta,#aah mov ta,#55h mov wdcon,#00000011b setb ewdi setb ea jmp $ ; wait time out
w79e201 publication release date: december 16, 2004 - 51 - revision a2 13. serial port serial port in the w79e201 is a full duplex port. the w79e201 provides the user with additional features such as the frame error detection and t he automatic address recognition. the serial ports are capable of synchronous as well as asynch ronous communication. in synchronous mode the w79e201 generates the clock and operates in a half duplex mode. in the asynchronous mode, full duplex operation is available. this means that it can simultaneously transmit and receive data. the transmit register and the receive buffer are bot h addressed as sbuf special function register. however any write to sbuf will be to the transmit register, while a read from sbuf will be from the receive buffer register. the serial port can operat e in four different modes as described below. mode 0 this mode provides synchronous communication with external devices. in this mode serial data is transmitted and received on the rxd line. txd is used to transmit the shift clock. the txd clock is provided by the w79e201 whether t he device is transmitting or receiv ing. this mode is therefore a half duplex mode of serial communication. in this m ode, 8 bits are transmitted or received per frame. the lsb is transmitted/received first. the baud rate is fixed at 1/12 or 1/4 of the oscillator frequency. this baud rate is determined by the sm2 bit (scon.5). when this bit is set to 0, then the serial port runs at 1/12 of the clock. when set to 1, the serial port runs at 1/4 of the clock. this additional facility of programmable baud rate in mode 0 is t he only difference between the standard 8051 and the w79e201. the functional block diagram is shown below. data enters and leaves the seri al port on the rxd line. the txd line is used to output the shift clock. the sh ift clock is used to shift data into and out of the w79e201 and the device at the other end of the line. any instruction t hat causes a write to sbuf will start the transmission. the shift clock will be activa ted and data will be shifted out on the rxd pin till all 8 bits are transmitted. if sm2 = 1, then the dat a on rxd will appear 1 clock period before the falling edge of shift clock on txd. the cl ock on txd then remains low for 2 clock periods, and then goes high again. if sm2 = 0, the data on rxd will appear 3 clo ck periods before the falling edge of shift clock on txd. the clock on txd then remains low for 6 cl ock periods, and then goes high again. this ensures that at the receiving end the dat a on rxd line can either be clock ed on the rising edge of the shift clock on txd or latched when the txd clock is low.
w79e201 - 52 - sbuf transmit shift register receive shift register tx shift parout internal data bus internal data bus rxd p3.0 alternate output function txd p3.1 alternate output function rxd p3.0 alternate iutput function serial port interrupt write to sbuf tx start sout ti ri ren parin load clock read sbuf sbuf tx clock ri serial controlle shift clock rx clock load sbuf rx start rx shift clock sin 4 12 1 0 sm2 osc serial port mode 1 the ti flag is set high in c1 following the end of trans mission of the last bit. the serial port will receive data when ren is 1 and ri is zero. the shift clock (txd) will be activated and the serial port will latch data on the rising edge of shift clock. the external device should therefore present data on the falling edge on the shift clock. this process continues till a ll the 8 bits have been received. the ri flag is set in c1 following the last rising edge of the shift clo ck on txd. this will stop re ception, till the ri is cleared by software. mode 1 in mode 1, the full duplex asynchronous mode is us ed. serial communication frames are made up of 10 bits transmitted on txd and received on rxd. the 10 bi ts consist of a start bit (0), 8 data bits (lsb first), and a stop bit (1). on received, the stop bi t goes into rb8 in the sfr scon. the baud rate in this mode is variable. the serial baud can be progra mmed to be 1/16 or 1/32 of the timer 1 overflow. since the timer 1 can be set to different reload values, a wide variation in baud rates is possible. transmission begins with a write to sbuf. the serial data is brought out on to txd pin at c1 following the first roll-over of divide by 16 counter. the nex t bit is placed on txd pin at c1 following the next rollover of the divide by 16 counter. thus the trans mission is synchronized to the divide by 16 counter and not directly to the write to sbuf signal. after a ll 8 bits of data are transmitted, the stop bit is transmitted. the ti flag is set in the c1 state a fter the stop bit has been put out on txd pin. this will be at the 10th rollover of the divide by 16 counter after a write to sbuf. reception is enabled only if ren is high. the serial por t actually starts the re ceiving of serial data, with the detection of a falling edge on the rxd pin. t he 1-to-0 detector continuously monitors the rxd line, sampling it at the rate of 16 times the selected baud rate. when a falling edge is detected, the divide by 16 counter is immediately reset. this helps to align the bit boundaries with the rollovers of the divide by 16 counter. the 16 states of the counter effect ively divide the bit time into 16 slices. the bit detection is done on a best of three bases. the bit detector samples the rxd pin, at the 8th, 9th and 10th counter states. by
w79e201 publication release date: december 16, 2004 - 53 - revision a2 using a majority 2 of 3 voting system, the bit val ue is selected. this is done to improve the noise rejection feature of the serial port. if the first bit detected after the falling edge of rxd pin is not 0, then this indicates an invalid start bit, and the reception is immediately aborted. the serial port again looks for a falling edge in the rxd line. if a valid start bit is detected, then the rest of the bits are also detected and shifted into the sbuf. after shifting in 8 data bits, there is one more shift to do, after which the sbuf and rb8 are loaded and ri is set. however certain conditions must be met before the loading and setting of ri can be done. 1. ri must be 0 and 2. either sm2 = 0, or the received stop bit = 1. if these conditions are met, then the stop bit goes to rb8, the 8 data bits go into sbuf and ri is set. otherwise the received frame may be lost. after the middle of the stop bit, the receiver goes back to looking for a 1-to-0 transition on the rxd pin. sbuf rb8 transmit shift register receive shift register tx shift parout d8 internal data bus internal data bus txd rxd serial port interrupt smod= tclk rclk sample write to sbuf tx start sout 0 1 0 1 ti 1 0 parin stop start load clock read sbuf timer 2 overflow timer 1 overflow tx clock ri serial controller rx clock load sbuf rx start rx shift 2 16 1-to-0 detector bit detector 16 clock sin 0 1 serial port mode 1 mode 2 this mode uses a total of 11 bits in asynch ronous full-duplex communication. the functional description is shown in the figure below. the frame cons ists of one start bit (0), 8 data bits (lsb first), a programmable 9th bit (tb8) and a stop bit (0). the 9t h bit received is put into rb8. the baud rate is programmable to 1/32 or 1/64 of the oscillator fr equency, which is determined by the smod bit in pcon sfr. transmission begins with a write to sbuf. the serial data is brought out on to txd pin at c1 following the first roll-over of the divide by 16 counter. the next bit is placed on txd pin at c1 following the next rollover of the divide by 16 count er. thus the transmission is synchronized to the
w79e201 - 54 - divide by 16 counter, and not directly to the writ e to sbuf signal. after all 9 bits of data are transmitted, the stop bit is transmitted. the ti flag is set in the c1 state after the stop bit has been put out on txd pin. this will be at the 11th rollover of the divide by 16 counter after a write to sbuf. reception is enabled only if ren is high. the serial por t actually starts the re ceiving of serial data, with the detection of a falling edge on the rxd pin. t he 1-to-0 detector continuously monitors the rxd line, sampling it at the rate of 16 times the selected baud rate. when a falling edge is detected, the divide by 16 counter is immediately reset. this helps to align the bit boundaries with the rollovers of the divide by 16 counter. the 16 states of the counter effectively divide the bit time into 16 slices. the bit detection is done on a best of three bases. the bit detector samples the rxd pin, at the 8th, 9th and 10th counter states. by using a ma jority 2 of 3 voting system, the bit value is selected. this is done to improve the noise rejecti on feature of the serial port. sbuf rb8 transmit shift register receive shift register tx shift parout d8 internal data bus internal data bus txd rxd serial port interrupt smod= sample write to sbuf tx start sout 0 1 ti parin stop start load clock read sbuf tx clock ri serial controlle rx clock load sbuf rx start rx shift 2 16 1-to-0 detector bit detector 16 clock sin d8 tb8 osc 0 1 serial port mode 2 if the first bit detected after the falling edge of rxd pin, is not 0, then this indicates an invalid start bit, and the reception is immediately aborted. the serial port again looks for a falling edge in the rxd line. if a valid start bit is detected, then the rest of t he bits are also detected and shifted into the sbuf. after shifting in 9 data bits, there is one more shift to do, after which the sbuf and rb8 are loaded and ri is set. however certain conditions must be met before the loading and setting of ri can be done. 1. ri must be 0 and 2. either sm2 = 0, or the received stop bit = 1. if these conditions are met, then the stop bit goes to rb8, the 8 data bits go into sbuf and ri is set. otherwise the received frame may be lost. after the middle of the stop bit, the receiver goes back to looking for a 1-to-0 transition on the rxd pin. mode 3
w79e201 publication release date: december 16, 2004 - 55 - revision a2 this mode is similar to mode 2 in all respects, ex cept that the baud rate is programmable. the user must first initialize the serial related sfr scon before any communication can take place. this involves selection of the mode and baud rate. the ti mer 1 should also be initialized if modes 1 and 3 are used. in all four modes, transmission is started by any instruction that uses sbuf as a destination register. reception is initiated in mode 0 by t he condition ri = 0 and ren = 1. this will generate a clock on the txd pin and shift in 8 bits on the rxd pin. reception is initiated in the other modes by the incoming start bit if ren = 1. the external device will start the communication by transmitting the start bit. sbuf rb8 transmit shift register receive shift register tx shift parout d8 internal data bus internal data bus txd rxd serial port interrupt smod = tclk rclk sample write to sbuf tx start sout 0 1 0 1 ti 1 0 parin stop start load clock read sbuf timer 2 overflow timer 1 overflow tx clock ri serial controller rx clock load sbuf rx start rx shift 2 16 1-to-0 detector bit detector 16 clock sin d8 tb8 0 1 serial port mode 3 table 10. serial ports modes sm1 sm0 mode type baud clock frame size start bit stop bit 9th bit function 0 0 0 synch. 4 or 12 t clks 8 bits no no none 0 1 1 asynch. timer 1 or 2 10 bits 1 1 none 1 0 2 asynch. 32 or 64 t clks 11 bits 1 1 0, 1 1 1 3 asynch. timer 1 or 2 11 bits 1 1 0, 1
w79e201 - 56 - 13.1 framing error detection a frame error occurs when a valid stop bit is not det ected. this could indicate incorrect serial data communication. typically the frame error is due to noise and contention on the serial communication line. the w79e201 has the facility to detect such framing errors and set a flag which can be checked by software. the frame error fe(fe_1) bit is located in scon.7 . this bit is normally used as sm0 in the standard 8051 family. however, in the w79e201 it serves a dual function and is called sm0/fe. there are actually two separate flags, one for sm0 and the other for fe. the flag that is actually accessed as scon.7 is determined by smod0 (pcon.6) bit. w hen smod0 is set to 1, then the fe flag is indicated in sm0/fe. when smod0 is set to 0, then the sm0 flag is indicated in sm0/fe. the fe bit is set to 1 by hardware but must be cl eared by software. note that smod0 must be 1 while reading or writing to fe. if fe is set, then any follo wing frames received without any error will not clear the fe flag. the clearing has to be done by software. 13.2 multiprocessor communications multiprocessor communications makes use of the 9t h data bit in modes 2 and 3. in the w79e201, the ri flag is set only if the received byte corresponds to the given or broadcast address. this hardware feature eliminates the software overhead required in checking every received address, and greatly simplifies the software programmer task. in the multiprocessor communication mode, the addr ess bytes are distinguis hed from the data bytes by transmitting the address with the 9th bit set high. when the master processor wants to transmit a block of data to one of the slaves, it first sends out the address of the target ed slave (or slaves). all the slave processors should have their sm2 bit set high when waiting for an address byte. this ensures that they will be interrupted only by the reception of a address byte. the automatic address recognition feature ensures that only the address ed slave will be interrupted. the address comparison is done in hardware not software. the addressed slave clears the sm2 bit, thereby clear ing the way to receive data bytes. with sm2 = 0, the slave will be interrupted on the reception of every single complete frame of data. the unaddressed slaves will be unaffected, as they will be st ill waiting for their address. in mode 1, the 9th bit is the stop bit, which is 1 in case of a valid frame. if sm2 is 1, then ri is set only if a valid frame is received and the received byte matches the given or broadcast address. the master processor can selectively communicate wi th groups of slaves by using the given address. all the slaves can be addressed together using t he broadcast address. the addresses for each slave are defined by the saddr and saden sfrs. the slav e address is an 8-bit value specified in the saddr sfr. the saden sfr is actually a mask for the byte value in saddr. if a bit position in saden is 0, then the corresponding bit position in saddr is don't care. only those bit positions in saddr whose corresponding bits in saden are 1 are used to obtain the given address. this gives the user flexibility to address multiple slav es without changing the slave address in saddr. the following example shows how the user can defi ne the given address to address different slaves. slave 1: saddr 1010 0100 saden 1111 1010 given 1010 0x0x
w79e201 publication release date: december 16, 2004 - 57 - revision a2 slave 2: saddr 1010 0111 saden 1111 1001 given 1010 0xx1 the given address for slave 1 and 2 differ in the lsb. fo r slave 1, it is a don't care, while for slave 2 it is 1. thus to communicate only with slave 1, the master must send an address with lsb = 0 (1010 0000). similarly the bit 1 position is 0 for slave 1 and don't care for slave 2. hence to communicate only with slave 2 the master has to transmit an address with bit 1 = 1 (1010 0011). if the master wishes to communicate with both slaves simult aneously, then the address must have bit 0 = 1 and bit 1 = 0. the bit 3 position is don't care for both the sl aves. this allows two different addresses to select both slaves (1010 0001 and 1010 0101). the master can communicate with all the slaves simultaneously with the broadcast address. this address is formed from the logical oring of t he saddr and saden sfrs. the zeros in the result are defined as don't cares in most cases the broadc ast address is ffh. in the previous case, the broadcast address is (1111111x) for slave 1 and (11111111) for slave 2. the saddr and saden sfrs are located at address a9h and b9h respectively. on reset, these two sfrs are initialized to 00h. this results in given address and broadcast address being set as xxxx xxxx(i.e. all bits don't care). this effectively re moves the multiprocessor communications feature, since any selectivity is disabled.
w79e201 - 58 - 14. pulse width modulated outputs (pwm) there are six pulse width modulated output channel s to generate pulses of programmable length and interval. the repetition frequency is defined by an 8- bit prescaler pwmp, which supplies the clock for the counter. the prescaler and counter are common to both pwm channels. the 8-bit counter counts modular 255 (0 ~ 254). the value of the 8-bit count er compared to the contents of six registers: pwm0, pwm1, pwm2, pwm3, pwm4 and pwm5. provided the contents of either these registers is greater than the counter value, the correspondi ng pwm0, pwm1, pwm2, pw m3, pwm4 or pwm5 output is set high. if the contents of these registers are equal to, or less than the counter value, the output will be low. the pulse-width-ratio is defined by the contents of the registers pwm0, pwm1, pwm2, pwm3, pwm4 and pwm5. the pulse-width-ra tio is in the range of 0 to 1 and may be programmed in increments of 1/255. enpw m0, enpwm1, enpwm2, enpwm3, enpwm4 and enpwm5 bit will enable or disable pwm output. buffered pwm outputs may be used to drive dc moto rs. the rotation speed of the motor would be proportional to the contents of pwm0 /1/2/3/4/5. the repetition frequency fpwm at the pwm0/1/2/3/4/5 output is given by: 255 pwmp) (1 2 fosc fpwm + = prescaler division factor = pwm + 1 pwmn high/low ratio of (pwmn) - 255 (pwmn) pwmn = this gives a repetition frequency range of 123 hz to 31.4k hz ( osc f = 16m hz). by loading the pwm registers with either 00h or ffh, the pwm channel s will output a constant high or low level, respectively. since the 8-bit counter counts modulo 255, it can never actually reach the value of the pwm registers when they are loaded with ffh. when a compare register (pwm0, pwm1, pwm2, pw m3, pwm4, pwm5) is loaded with a new value, the associated output updated immediately. it does not have to wait until the end of the current counter period. there is w eakly pulled high on pwm output.
w79e201 publication release date: december 16, 2004 - 59 - revision a2 8-bits counter pwm0 register pwmp register + - pwm1 register + - pwm2 register + - pwm3 register + - pwm2 (p0.4) pwm3 (p0.5) pwm1 (p0.3) pwm0 (p0.2) + - x x x x y y y y > > > > 1/2 fosc enpwm 0/1/2/3/4/5 pwm4 register + - pwm4 (p0.6) x y > pwm5 register + - pwm5 (p0.7) x y > pwm0oe pwm1oe pwm2oe pwm3oe pwm4oe pwm5oe pwm block diagram
w79e201 - 60 - 15. analog-to-digital converter the adc contains a dac which converts the cont ents of a successive approx imation register to a voltage (v dac ) which is compared to the analog input voltage (vin). the output of the comparator is fed to the successive approximation control logi c which controls the successive approximation register. a conversion is initiated by setting a dcs in the adccon register. adcs can be set by software only or by either har dware (p2.0) or software. before used adc circuit, it must enabled by adcce n. the software only start mode is selected when control bit adccon.5 (adex) =0. a conversion is then started by setti ng control bit adccon.3 (adcs) the hardware or software start mode is selected when adccon.5 =1, and a conversion may be started by setting adccon.3 as above or by applying a rising edge to external pin stadc. when a conversion is started by applyi ng a rising edge, a low level must be applied to stadc for at least one machine cycle followed by a high level for at least one machine cycle. the low-to-high transition of stadc is recognized at the end of a machine cycle, and the conversion commences at the beginning of the next cycle. v dac dac successive approximation register successive approximation control logic start ready (stop) msb lsb comparator vin successive approximation adc the end of the 10-bit conversion is flagged by contro l bit adccon.4 (adci). the upper 8 bits of the result are held in special function register adch, and the two remaining bits are held in adccon.7 (adc.1) and adccon.6 (adc.0). the user may ignore the two least significant bits in adccon and use the adc as an 8-bit converter (8 upper bits in adch). in any event, the total actual conversion time is 50 machine cycles. adc will be set and the adcs status flag will be reset 50 cycles after the adcs is set.
w79e201 publication release date: december 16, 2004 - 61 - revision a2 control bits adccon.0, adccon. 1 and adccon.2 are used to control an analog multiplexer which selects one of eight analog channels. an adc conversion in progress is unaffected by an external or software adc start. the result of a completed conv ersion remains unaffected pr ovided adci = logic 1; a new adc conversion already in progress is abort ed when the idle or power down mode is entered. the result of a completed conv ersion (adci = logic 1) remains unaffected when entering the idle mode. adc resolution and analog supply: the adc has its own supply pins (avdd and avss ) and one pins (vref+) connected to each end of the dac?s resistance-ladder. the ladder has 1023 equa lly spaced taps, separated by a resistance of ?r?. the first tap is located 0. 5xr above avss, and the last tap is located 0.5xr below vref+. this gives a total ladder resistance of 1024xr. this structure ensures that the dac is monotonic and results in a symmetrical quantization error. for input voltages between avss and [(vref+) + ? lsb ], the 10-bit result of an a/d conversion will be 00 0000 0000 b = 000h. for input voltages between [(vref +) ? 3/2 lsb] and vref+, the result of a conversion will be 11 1111 1111b = 3ffh. avref+ and avss may be between av dd + 0.2v and av ss ? 0.2 v. avref+ should be positive with res pect to avss, and the input voltage (vin) should be between avref+ and avss. the result can always be calculated from the following formula: result = av vin 1024 ref +
w79e201 - 62 - adc0 adc7 analog input multiplexer vin avdd aadr0 aadr1 aadr2 0 1 2 3 4 5 6 7 adcon adcs adci adex 0 1 2 3 4 5 6 7 adc.0 adc.1 adc.2 adc.3 adc.4 adc.5 adc.6 adc.7 adc.8 adc.9 adch 10-bit a/d converter avss stadc avref+ adc functional block diagram
w79e201 publication release date: december 16, 2004 - 63 - revision a2 16. timed access protection the w79e201 has several new features, like the wa tchdog timer, on-chip rom size adjustment, wait state control signal and power on/fail reset flag, whic h are crucial to proper operation of the system. if left unprotected, errant code may write to the watc hdog control bits resulting in incorrect operation and loss of control. in order to prevent this, t he w79e201 has a protection scheme which controls the write access to critical bits. this prot ection scheme is done using a timed access. in this method, the bits which are to be prot ected have a timed write enable window. a write is successful only if this window is active, otherwise the write will be discarded. this write enable window is open for 3 machine cycles if certain conditions are met. after 3 machine cycles, this window automatically closes. the window is opened by writ ing aah and immediately 55h to the timed access (ta) sfr. this sfr is located at address c 7h. the suggested code for opening the timed access window is ta reg 0c7h ; define new register ta, located at 0c7h mov ta, #0aah mov ta, #055h when the software writes aah to the ta sfr, a count er is started. this counter waits for 3 machine cycles looking for a write of 55h to ta. if the second write (55h) occurs within 3 machine cycles of the first write (aah), then the timed access window is opened. it remains open for 3 machine cycles, during which the user may write to the protected bits. once the window closes the procedure must be repeated to access the other protected bits. examples of timed assessing are shown below. example 1: valid access mov ta, #0aah 3 m/c ; note: m/c = machine cycles mov ta, #055h 3 m/c mov wdcon, #00h 3 m/c example 2: valid access mov ta, #0aah 3 m/c mov ta, #055h 3 m/c nop 1 m/c setb ewt 2 m/c example 3: valid access mov ta, #0aah 3 m/c mov ta, #055h 3 m/c orl wdcon, #00000010b 3m/c example 4: invalid access mov ta, #0aah 3 m/c mov ta, #055h 3 m/c
w79e201 - 64 - nop 1 m/c nop 1 m/c clr por 2 m/c example 5: invalid access mov ta, #0aah 3 m/c nop 1 m/c mov ta, #055h 3 m/c setb ewt 2 m/c in the first two examples, the writing to the prot ected bits is done before the 3 machine cycle window closes. in example 3, however, the writing to the protected bit occurs after the window has closed, and so there is effectively no change in the status of the protected bit. in ex ample 4, the second write to ta occurs 4 machine cycles after the first wr ite, therefore the timed access window in not opened at all, and the write to the protected bit fails. 17. h/w reboot mode (boot from 4k bytes of ld flash eprom) the w79e201 boots from ap flash eprom program (16k bytes) by default at the external reset. on some occasions, user can force w79e201 to boot fr om the ld flash eprom program (4k bytes) at the external reset. the set for this special mode is as follow. it is necessary to add 10k resistor on p4.0 pins. reboot mode option bits rst p4.0 mode bit3 l h l reboot p4.0 rst 20 us the reset timing for entering reboot mode 10 ms hi-z notes: 1: in application system design, user must take care t he p4.0, ale, /ea and /psen pin value at reset to avoid w79e201 entering the programming mode or reboot mode in normal operation.
w79e201 publication release date: december 16, 2004 - 65 - revision a2 18. in-system programming 18.1 the loader program locates at ld flash eprom memory cpu is free run at ap flash eprom memory. chpcon register had been set #03h value before cpu has entered idle state. cpu w ill switch to ld flash eprom memory and execute a reset action. h/w reboot mode will switch to ld flash eprom me mory, too. set sfrcn register where it locates at user's loader program to update ap flash epr om memory. set a swreset (chpcon=#83h) to switch back ap flash eprom after cpu has updated ap flash eprom program. cpu will restart to run program from reset state. 18.2 the loader program locates at ap flash eprom memory cpu is free run at ap flash eprom memory. chpcon register had been set #01h value before cpu has entered idle state. set sfrcn register to update ld flash eprom program. cpu will continue to run user's ap flash eprom progr am after cpu has updated program. please refer demonstrative code to understand other detail description. 19. h/w writer mode this mode is for the writer to write / read flash eprom operation. a general user may not enter this mode. psen ea ale p2.7 p2.6 p3.7 p3.6 rst 300ms hi-z hi-z hi-z hi-z hi-z hi-z hi-z the timing for entering flash eprom mode on the programmer 10ms
w79e201 - 66 - 20. security bits using device programmer, the flash eprom can be programmed and verified repeatedly. until the code inside the flash eprom is confirmed ok, the code can be protected. the protection of flash eprom and those operations on it are described bel ow. the w79e201 has special setting register which can be accessed by device programmer. the register can only be accessed from the flash eprom operation mode. those bits of the secu rity registers can not be changed once they have been programmed from high to low. they can only be reset through erase-all operation. b2: 0 -> encryption b0 b1 security bits b2 b3 reserved b3: 0 -> enable h/w reboot with p4.0 b1: 0 -> movc inhibuted b0: 0 -> data out lock default 1 for each bit. b0: lock bit this bit is used to protect the customer's pr ogram code in the w79e201. it may be set after the programmer finishes the programming and verifies sequenc e. once this bit is set to logic 0, both the flash eprom data and special setting registers can not be accessed again. b1: movc inhibit this bit is used to restrict the accessible region of the movc instruction. it can prevent the movc instruction in external program memory from reading the internal program code. when this bit is set to logic 0, a movc instruction in external program memory space will be able to access code only in the external memory, not in the internal memory. a mo vc instruction in internal program memory space will always be able to access the rom data in both inte rnal and external memory. if this bit is logic 1, there are no restrictions on the movc instruction. b2: encryption this bit is used to enable/disable the encryption logi c for code protection. once encryption feature is enabled, the data presented on port 0 will be encoded via enc ryption logic. only whole chip erase will reset this bit. b3: h/w reboot with p4.0 if this bit is set to logic 0, enable to reboot 4k ld flash eprom mode while rst =h and p4.0 = l state. cpu will start from ld flas h eprom to update the user?s program
w79e201 publication release date: december 16, 2004 - 67 - revision a2 21. the performance characteristic of adc offset error the offset error is the deviation between i deal transfer value and actual transfer value. gain error the gain error is the difference between the slope of ideal transfer curve and the slope of actual transfer curve. differential nonlinearity (dnl) the differential non-linearity is the difference betw een the actual step width and ideal step width. the ideal step width is 1 lsb. the characte ristic of dnl is as below figure. integral nonlinearity (inl) the integral non-linearity is the deviation of a code from actual straight line. the deviation of each code is measured from middle of this code. the characteristic of inl is as below figure. 21.1 the differential nonlinearity vs output code v dd ? v ss = 5v 10%, av dd ? v ss =5v, vref=5v , t a = 25 c, fosc = 16 mhz differential nonlinearity vs output code -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1 1 27 53 79 105 131 157 183 209 235 261 287 313 339 365 391 417 443 469 495 521 547 57 3 599 625 651 677 703 729 755 781 807 833 859 885 911 937 963 989 1015 output code dnl error (dnl)
w79e201 - 68 - 21.2 the integral nonlinearity vs output code v dd ? v ss = 5v 10%, av dd ? v ss = 5v, vref = 5v , t a = 25 c, fosc = 16 mhz integral nonlinearity vs output code -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1 27 53 79 105 131 157 183 209 235 261 287 313 339 365 391 417 443 469 495 521 547 57 3 599 625 651 677 703 729 755 781 807 833 859 885 911 937 963 9891015 output code inl error (inl) 22. the embedded ice with jtag interface the w79e201a16ln is packaged in 48-pins lqfp with t he function of in-circuit emulation (ice). the embedded ice provides the below functions. eight breakpoints to detect program counter two enhanced watch breakpoints that can hold progr am by observing cpu access to data memory and flash rom read/write data memory when program holds write application code to flash rom
w79e201 publication release date: december 16, 2004 - 69 - revision a2 23. electrical characteristics 23.1 absolute maximum ratings symbol parameter condition rating unit dc power supply v dd ? v ss -0.3 +7.0 v input voltage v in v ss -0.3 v dd +0.3 v operating temperature t a 0 +70 c storage temperature tst -55 +150 c note: exposure to conditions beyond those listed under absolute maxi mum ratings may adversely affect the life and reliability of the device. 23.2 dc characteristics (v dd ? v ss = 5v 10%, t a = 25 c, fosc = 16 mhz, unless otherwise specified.) specification parameter symbol min. max. unit test conditions operating voltage v dd 4.5 5.5 v operating current i dd - 30 ma no load v dd = rst = 5.5v idle current i idle - 24 ma idle mode v dd = 5.5v power down current i pwdn - 10 a power-down mode v dd = 5.5v input current p1, p2, p3 i in1 -50 +10 a v dd = 5.5v v in = 0v or v dd input current rst [*1] i in2 -10 +120 a v dd = 5.5v 0 w79e201 - 70 - dc characteristics, continued specification parameter symbol min. max. unit test conditions input low voltage xtal1 [*3] v il3 0 0.8 v v dd = 4.5v input high voltage p0, p1, p2, p3, ea v ih1 2.4 v dd +0.2 v v dd = 5.5v input high voltage rst v ih2 3.5 v dd +0.2 v v dd = 5.5v input high voltage xtal1 [*3] v ih3 3.5 v dd +0.2 v v dd = 5.5v sink current p1, p3 i sk1 4 10 ma v dd =4.5v vs = 0.45v sink current p0,p2, ale, psen i sk2 8 12 ma v dd =4.5v v ol = 0.45v source current p1, p3 i sr1 -180 -360 ua v dd =4.5v v ol = 2.4v source current p0, p2, ale, psen i sr2 -10 -14 ma v dd =4.5v v ol = 2.4v output low voltage p1, p3 v ol1 - 0.45 v v dd = 4.5v i ol = +6 ma output low voltage p0, p2, ale, psen [*2] v ol2 - 0.45 v v dd = 4.5v i ol = +10 ma output high voltage p1, p3 v oh1 2.4 - v v dd = 4.5v i oh = -180 a output high voltage p0, p2, ale, psen [*2] v oh2 2.4 - v v dd = 4.5v i oh = -10ma notes: *1. rst pin is a schmitt trigger input. *2. p0, ale and psen are tested in the external access mode. *3. xtal1 is a cmos input. *4. pins of p1, p2, p3 can source a transition current when they are being externally driven from 1 to 0. the transition current reaches its maximum value when vin approximates to 2v.
w79e201 publication release date: december 16, 2004 - 71 - revision a2 23.3 adc dc electrical characteristics (av dd - av ss = 5v 10%, t a = 25 c, fosc = 16mhz, unless otherwise specified.) specification parameter sym. min. max. unit test conditions analog input avin avss-0.2 avdd+0.2 v reference voltage avref - avdd+0.2 v resistance between avref and avss rref 10 50 k ? when adc is enabled conversion time t c 52t mc s t mc is machine cycle offset error ofe -2 +2 lsb gain error ge -0.4 +0.4 % differential non-linearity dnl -1 +1 lsb integral non-linearity inl -2 +2 lsb 23.4 ac characteristics t clcl t clcx t chcx t clch t chcl clock note: duty cycle is 50%. external clock characteristics parameter symbol min. typ. max. units notes clock high time t chcx 12 - - ns clock low time t clcx 12 - - ns clock rise time t clch - - 10 ns clock fall time t chcl - - 10 ns
w79e201 - 72 - 23.4.1 ac specification parameter symbol variable clock min. variable clock max. units oscillator frequency 1/t clcl 0 16 mhz ale pulse width t lhll 1.5t clcl - 5 ns address valid to ale low t avll 0.5t clcl - 5 ns address hold after ale low t llax1 0.5t clcl - 5 ns address hold after ale low for movx write t llax2 0.5t clcl - 5 ns ale low to valid instruction in t lliv 2.5t clcl - 20 ns ale low to psen low t llpl 0.5t clcl - 5 ns psen pulse width t plph 2.0t clcl - 5 ns psen low to valid instruction in t pliv 2.0t clcl - 20 ns input instruction hold after psen t pxix 0 ns input instruction float after psen t pxiz t clcl - 5 ns port 0 address to valid instr. in t aviv1 3.0t clcl - 20 ns port 2 address to valid instr. in t aviv2 3.5t clcl - 20 ns psen low to address float t plaz 0 ns data hold after read t rhdx 0 ns data float after read t rhdz t clcl - 5 ns rd low to address float t rlaz 0.5t clcl - 5 ns
w79e201 publication release date: december 16, 2004 - 73 - revision a2 23.4.2 movx characteristics using stretch memory cycle parameter sym. variable clock min. variable clock max. units strech data access ale pulse width t llhl2 1.5t clcl - 5 2.0t clcl - 5 ns t mcs = 0 t mcs >0 address hold after ale low for movx write t llax2 0.5t clcl - 5 ns rd pulse width t rlrh 2.0t clcl - 5 t mcs - 10 ns t mcs = 0 t mcs >0 wr pulse width t wlwh 2.0t clcl - 5 t mcs - 10 ns t mcs = 0 t mcs >0 rd low to valid data in t rldv 2.0t clcl - 20 t mcs - 20 ns t mcs = 0 t mcs >0 data hold after read t rhdx 0 ns data float after read t rhdz t clcl - 5 2.0t clcl - 5 ns t mcs = 0 t mcs >0 ale low to valid data in t lldv 2.5t clcl - 5 t mcs + 2t clcl - 40 ns t mcs = 0 t mcs >0 port 0 address to valid data in t avdv1 3.0t clcl - 20 2.0t clcl - 5 ns t mcs = 0 t mcs >0 ale low to rd or wr low t llwl 0.5t clcl - 5 1.5t clcl - 5 0.5t clcl + 5 1.5t clcl + 5 ns t mcs = 0 t mcs >0 port 0 address to rd or wr low t avwl t clcl - 5 2.0t clcl - 5 ns t mcs = 0 t mcs >0 port 2 address to rd or wr low t avwl2 1.5t clcl - 5 2.5t clcl - 5 ns t mcs = 0 t mcs >0 data valid to wr transition t qvwx -5 1.0t clcl - 5 ns t mcs = 0 t mcs >0 data hold after write t whqx t clcl - 5 2.0t clcl - 5 ns t mcs = 0 t mcs >0 rd low to address float t rlaz 0.5t clcl - 5 ns rd or wr high to ale high t whlh 0 1.0t clcl - 5 10 1.0t clcl + 5 ns t mcs = 0 t mcs >0
w79e201 - 74 - note: the t mcs is a time period related to the stretch memory cycle se lection. the following table shows the time period of the t mcs for each selection of the stretch value. m2 m1 m0 movx cycles t mcs 0 0 0 2 machine cycles 0 0 0 1 3 machine cycles 4 t clcl 0 1 0 4 machine cycles 8 t clcl 0 1 1 5 machine cycles 12 t clcl 1 0 0 6 machine cycles 16 t clcl 1 0 1 7 machine cycles 20 t clcl 1 1 0 8 machine cycles 24 t clcl 1 1 1 9 machine cycles 28 t clcl explanation of logics symbols in order to maintain compatibility with the orig inal 8051 family, this device specifies the same parameter for each device, using the same symbols. the explanation of the symbols is as follows. t time a address c clock d input data h logic level high l logic level low i instruction p psen q output data r rd signal v valid w wr signal x no longer a valid state z tri-state
w79e201 publication release date: december 16, 2004 - 75 - revision a2 23.4.3 program memory read cycle t llax1 t pxiz t plaz t llpl t pxix t pliv t aviv2 t aviv1 t plph t avll address a8-a15 address a8-a15 address a0-a7 instruction in address a0-a7 port 2 port 0 psen ale t lliv t lhll 23.4.4 data memory read cycle t avll t avwl1 t llax1 t whlh t rldv t rlrh t rlaz t rhdz t rhdx t avdv2 t avdv1 t llwl address a8-a15 address a0-a7 instruction in data in address a0-a7 port 2 port 0 psen rd ale t lldv
w79e201 - 76 - 23.4.5 data memory write cycle t avll t avwl1 t llax2 t whlh t wlwh t qvwx t whqx t avdv2 t llwl address a8-a15 address a0-a7 instruction in data out address a0-a7 port 2 port 0 psen wr ale
w79e201 publication release date: december 16, 2004 - 77 - revision a2 24. typical application circuits expanded external program memory and crystal ad0 a0 a0 a0 10 a1 9 a2 8 a3 7 a4 6 a5 5 a6 4 a7 3 a8 25 a9 24 a10 21 a11 23 a12 2 a13 26 a14 27 a15 1 ce 20 oe 22 o0 11 o1 12 o2 13 o3 15 o4 16 o5 17 o6 18 o7 19 27512 ad0 d0 3 q0 2 d1 4 q1 5 d2 7 q2 6 d3 8 q3 9 d4 13 q4 12 d5 14 q5 15 d6 17 q6 16 d7 18 q7 19 oc 1 g 11 74f373 ad0 ea 31 xtal1 19 xtal2 18 rst 9 int0 12 int1 13 t0 14 t1 15 p1.0 1 p1.1 2 p1.2 3 p1.3 4 p1.4 5 p1.5 6 p1.6 7 p1.7 8 39 38 37 36 35 34 33 32 21 22 23 24 25 26 27 28 17 wr p0.0 p0.1 p0.2 p0.3 p0.4 p0.5 p0.6 p0.7 p2.0 p2.1 p2.2 p2.3 p2.4 p2.5 p2.6 p2.7 rd 16 psen 29 ale 30 txd 11 rxd 10 w79e201 10 u 8.2 k cc crystal c1 c2 r ad1 ad2 ad3 ad4 ad5 ad6 ad7 a8 ad1 ad2 ad3 ad4 ad5 ad6 ad7 gnd a1 a2 a3 a4 a5 a6 a7 a1 a2 a3 a4 a5 a6 a7 a8 a9 ad1 ad2 ad3 ad4 ad5 ad6 ad7 a10 a11 a12 a13 a14 a15 gnd a9 a10 a11 a12 a13 a14 a15 v cc v figure a crystal c1 c2 r 12 mhz not necessary not necessary not necessary 16 mhz not necessary not necessary not necessary pull ea low to let cpu fetches code in the embedded fl ash rom when the program counter is lower than 16k and as the program counter is higher than 16k the cpu will fetch program code from extended external program memory automatically.
w79e201 - 78 - expanded external data memory and oscillator 10 u 8.2 k cc oscillator ea 31 xtal1 19 xtal2 18 rst 9 int0 12 int1 13 t0 14 t1 15 1 2 3 4 5 6 p1.0 p1.1 p1.2 p1.3 p1.4 p1.5 p1.6 7 p1.7 8 p0.0 39 p0.1 38 p0.2 37 p0.3 36 p0.4 35 p0.5 34 p0.6 33 p0.7 32 p2.0 21 p2.1 22 p2.2 23 p2.3 24 p2.4 25 p2.5 26 p2.6 27 p2.7 28 rd 17 wr 16 psen 29 ale 30 txd 11 rxd 10 w79e201 ad0 ad1 ad2 ad3 ad4 ad5 ad6 ad7 ad0 ad1 ad2 ad3 ad4 ad5 ad6 ad7 a0 a1 a2 a3 a4 a5 a6 a7 d0 3 q0 2 d1 4 q1 5 d2 7 q2 6 d3 8 q3 9 d4 13 q4 12 d5 14 q5 15 d6 17 q6 16 d7 18 q7 19 oc 1 g 11 74f373 a0 a1 a2 a3 a4 a5 a6 a7 10 9 8 7 6 5 4 3 a0 a1 a2 a3 a4 a5 a6 a7 ad0 ad1 ad2 ad3 ad4 ad5 ad6 ad7 11 12 13 15 16 17 18 19 d0 d1 d2 d3 d4 d5 d6 d7 a8 a9 a10 a11 a12 a13 a14 25 24 21 23 26 1 20 2 a8 a9 a10 a11 a12 a13 a14 ce gnd a8 a9 a10 a11 a12 a13 a14 gnd 22 27 oe wr 20256 v cc v figure b
w79e201 publication release date: december 16, 2004 - 79 - revision a2 25. package dimensions 44-pin qfp seating plane 11 22 12 see detail f e b a y 1 a a l l 1 c e e h 1 d 44 h d 34 33 detail f 1. dimension d & e do not include interlead flash. 2. dimension b does not include dambar protrusion/intrusion. 3. controlling dimension: millimeter 4. general appearance spec. should be based on final visual inspection spec. 0.254 0.101 0.010 0.004 notes: symbol min. nom. max. max. nom. min. dimension in inch dimension in mm a b c d e h d h e l y a a l 1 1 2 e 0.006 0.152 --- 0.002 0.075 0.01 0.081 0.014 0.087 0.018 1.90 0.25 0.05 2.05 0.35 2.20 0.45 0.390 0.025 0.063 0.003 0 7 0.394 0.031 0.398 0.037 9.9 0.80 0.65 1.6 10.00 0.8 10.1 0.95 0.398 0.394 0.390 0.530 0.520 0.510 13.45 13.2 12.95 10.1 10.00 9.9 7 0 0.08 0.031 0.01 0.02 0.25 0.5 --- --- --- --- --- 2 0.025 0.036 0.635 0.952 0.530 0.520 0.510 13.45 13.2 12.95 0.051 0.075 1.295 1.905 44-pin plcc 44 40 39 29 28 18 17 7 61 l c 1 b 2 a h d d e b e h e y a a 1 seating plane d g g e symbol min. nom. max. max. nom. min. dimension in inches dimension in mm a b c d e h e l y a a 1 2 e b 1 h d g g d e notes: on final visual inspection spec. 4. general appearance spec. should be based 3. controlling dimension: inches protrusion/intrusion. 2. dimension b1 does not include dambar flash. 1. dimension d & e do not include interlead 0.020 0.145 0.026 0.016 0.008 0.648 0.590 0.680 0.090 0.150 0.028 0.018 0.010 0.653 0.610 0.690 0.100 0.050 bsc 0.185 0.155 0.032 0.022 0.014 0.658 0.630 0.700 0.110 0.004 0.508 3.683 0.66 0.406 0.203 16.46 14.99 17.27 2.296 3.81 0.711 0.457 0.254 16.59 15.49 17.53 2.54 1.27 4.699 3.937 0.813 0.559 0.356 16.71 16.00 17.78 2.794 0.10 bsc 16.71 16.59 16.46 0.658 0.653 0.648 16.00 15.49 14.99 0.630 0.610 0.590 17.78 17.53 17.27 0.700 0.690 0.680
w79e201 - 80 - 48-pin lqfp 2 1 a h d d e b e h e y a a seating plane l l 1 see detail f detail f c 37 48 1 12 13 24 25 36 1. dimensions d & e do not include interlead flash. 2. dimension b does not include dambar protrusion/intrusion. 3. controlling dimension: millimeters 4. general appearance spec. should be based on final visual inspection spec. notes: max. nom. min. dimension in mm symbol a b c d e h d h e l y 0 a a l 1 1 2 e 1.40 0.20 0.50 1.00 7.00 9.00 9.00 7.00 --- --- --- 1.60 0.15 1.45 1.35 0.05 0.17 0.27 --- 0.09 0.20 0.45 0.60 0.75 0.08 0 3.5 7 --- ---
w79e201 publication release date: december 16, 2004 - 81 - revision a2 26. application note in-system programming software examples this application note illustrates the in-syste m programmability of the winbond w79e201 flash eprom microcontroller. in this exampl e, microcontroller will boot from 16 kb ap flash eprom and waiting for a key to enter in-system programmi ng mode for re-programming the contents of 16 kb ap flash eprom. while entering in-system programmi ng mode, microcontroller executes the loader program in 4kb ld flash eprom. the loader program erases the 16 kb ap flash eprom then reads the new code data from external sram buffe r (or through other interfaces) to update the 16kb ap flash eprom. if the customer uses the reboot mode to update his pr ogram, please enable this b3 of security bit from the writer. please refer security bits for detail description example 1: ;******************************************************************************************************************* ;* example of 64k ap flash eprom program: program wi ll scan the p1.0. if p1.0 = 0, enters in-system ;* programming mode for updating the content of ap flas h eprom code else executes the current rom code. ;* xtal = 24 mhz ;******************************************************************************************************************* .chip 8052 .ramchk off .symbols chpcon equ 9fh ta equ c7h sfral equ ach sfrah equ adh sfrfd equ aeh sfrcn equ afh org 0h ljmp 100h ; jump to main program ; ************************************************************************ ;* timer0 service vector org = 000bh ;************************************************************************ org 00bh clr tr0 ; tr0 = 0, stop timer0 mov tl0,r6 mov th0,r7 reti
w79e201 - 82 - ;************************************************************************ ;* 64k ap flash eprom main program ;************************************************************************ org 100h main_64k: mov a,p1 ; scan p1.0 anl a,#01h cjne a,#01h,program_64k ; if p1.0 = 0, enter in-system programming mode jmp normal_mode program_64: mov ta, #aah ; chpcon register is written protect by ta register. mov ta, #55h mov chpcon, #03h ; chpcon = 03h, enter in-system programming mode mov sfrcn, #0h mov tcon, #00h ; tr = 0 timer0 stop mov ip, #00h ; ip = 00h mov ie, #82h ; timer0 interrupt enable for wake-up from idle mode mov r6, #f0h ; tl0 = f0h mov r7, #ffh ; th0 = ffh mov tl0, r6 mov th0, r7 mov tmod, #01h ; tmod = 01h, set timer0 a 16-bit timer mov tcon, #10h ; tcon = 10h, tr0 = 1,go mov pcon, #01h ; enter idle mode for launching the in-system programming ;************** ****************************************************************** ;* normal mode 64kb ap flash eprom program: depending user's application ;******************************************************************************** normal_mode: . ; user's application program . . .
w79e201 publication release date: december 16, 2004 - 83 - revision a2 example 2: ;***************************************************************************************************************************** ;* example of 4kb ld flash eprom program: this loader program will erase the 64kb ap flash eprom first, ;* then reads the new code from external sr am and program them into 64kb ap flash eprom. ;* xtal = 24 mhz ;***************************************************************************************************************************** .chip 8052 .ramchk off .symbols chpcon equ 9fh ta equ c7h sfral equ ach sfrah equ adh sfrfd equ aeh sfrcn equ afh org 000h ljmp 100h ; jump to main program ;************************************************************************ ;* 1. timer0 service vector org = 0bh ;************************************************************************ org 000bh clr tr0 ; tr0 = 0, stop timer0 mov tl0, r6 mov th0, r7 reti ;************************************************************************ ;* 4kb ld flash eprom main program ;************************************************************************ org 100h main_4k: mov ta,#aah mov ta,#55h mov chpcon,#03h ; chpcon = 03h, enable in-system programming. mov sfrcn,#0h mov tcon,#00h ; tcon = 00h, tr = 0 timer0 stop mov tmod,#01h ; tmod = 01h, set timer0 a 16bit timer
w79e201 - 84 - mov ip,#00h ; ip = 00h mov ie,#82h ; ie = 82h, timer0 interrupt enabled mov r6,#f0h mov r7,#ffh mov tl0,r6 mov th0,r7 mov tcon,#10h ; tcon = 10h, tr0 = 1, go mov pcon,#01h ; enter idle mode update_64k: mov tcon,#00h ; tcon = 00h , tr = 0 tim0 stop mov ip,#00h ; ip = 00h mov ie,#82h ; ie = 82h, timer0 interrupt enabled mov tmod,#01h ; tmod = 01h, mode1 mov r6,#d0h ; set wake-up time for erase operation, about 15 ms ;depending on user's system clock rate. mov r7,#8ah mov tl0,r6 mov th0,r7 erase_p_4k: mov sfrcn,#22h ; sfrcn = 22h, erase 64k ap flash eprom mov tcon,#10h ; tcon = 10h, tr0 = 1,go mov pcon,#01h ; enter idle mode (for erase operation) ;********************************************************************* ;* blank check ;********************************************************************* mov sfrcn,#0h ; sfrcn = 00h, read 64kb ap flash eprom mov sfrah,#0h ; start address = 0h mov sfral,#0h mov r6,#fdh ; set timer for read operation, about 1.5 s. mov r7,#ffh mov tl0,r6 mov th0,r7 blank_check_loop: setb tr0 ; enable timer 0 mov pcon,#01h ; enter idle mode mov a,sfrfd ; read one byte cjne a,#ffh,blank_check_error inc sfral ; next address mov a,sfral
w79e201 publication release date: december 16, 2004 - 85 - revision a2 jnz blank_check_loop inc sfrah mov a,sfrah cjne a,#0h,blank_check_loop ; end address = ffffh jmp program_64krom blank_check_error: jmp $ ;******************************************************************************* ;* re-programming 64kb ap flash eprom bank ;******************************************************************************* program_64krom: mov r2,#00h ; target low byte address mov r1,#00h ; target high byte address mov dptr,#0h mov sfrah,r1 ; sfrah, target high address mov sfrcn,#21h ; sfrcn = 21h, program 16k ap flash eprom mov r6,#9ch ; set timer for programming, about 50 s. mov r7,#ffh mov tl0,r6 mov th0,r7 prog_d_64k: mov sfral,r2 ; sfral = low byte address call get_byte_from_pc_to_acc ; this program is based on user?s circuit. mov @dptr,a ; save data into sram to verify code. mov sfrfd,a ; sfrfd = data in mov tcon,#10h ; tcon = 10h, tr0 = 1,go mov pcon,#01h ; enter idle mode (prorgamming) inc dptr inc r2 cjne r2,#0h,prog_d_64k inc r1 mov sfrah,r1 cjne r1,#0h,prog_d_64k ;***************************************************************************** ; * verify 16kb ap flash eprom bank ;***************************************************************************** mov r4,#03h ; error counter mov r6,#fdh ; set timer for read verify, about 1.5 s.
w79e201 - 86 - mov r7,#ffh mov tl0,r6 mov th0,r7 mov dptr,#0h ; the start address of sample code mov r2,#0h ; target low byte address mov r1,#0h ; target high byte address mov sfrah,r1 ; sfrah, target high address mov sfrcn,#00h ; sfrcn = 00h, read ap flash eprom read_verify_64k: mov sfral,r2 ; sfral = low address mov tcon,#10h ; tcon = 10h, tr0 = 1,go mov pcon,#01h inc r2 movx a,@dptr inc dptr cjne a,sfrfd,error_64k cjne r2,#0h,read_verify_64k inc r1 mov sfrah,r1 cjne r1,#0h,read_verify_64k ;****************************************************************************** ;* programming completly, software reset cpu ;****************************************************************************** mov ta,#aah mov ta,#55h mov chpcon,#83h ; software reset. cpu will restart from ap flash eprom error_64k: djnz r4,update_64k ; if error occurs, repeat 3 times. ; in-syst programming fail , user's process to deal with it. . . .
w79e201 publication release date: december 16, 2004 - 87 - revision a2 27. revision history version date page description a1 november 9, 2004 - initial issued a2 december 16, 2004 58 / 60 1. to add pwm function description 2. to add adc function description headquarters no. 4, creation rd. iii, science-based industrial park, hsinchu, taiwan tel: 886-3-5770066 fax: 886-3-5665577 http://www.winbond.com.tw/ taipei office tel: 886-2-8177-7168 fax: 886-2-8751-3579 winbond electronics corporation america 2727 north first street, san jose, ca 95134, u.s.a. tel: 1-408-9436666 fax: 1-408-5441798 winbond electronics (h.k.) ltd. no. 378 kwun tong rd., kowloon, hong kong fax: 852-27552064 unit 9-15, 22f, millennium city, tel: 852-27513100 please note that all data and specifications are subject to change without notice. all the trade marks of products and companies mentioned in this data sheet belong to their respective owners. winbond electronics (shanghai) ltd. 200336 china fax: 86-21-62365998 27f, 2299 yan an w. rd. shanghai, tel: 86-21-62365999 winbond electronics corporation japan shinyokohama kohoku-ku, yokohama, 222-0033 fax: 81-45-4781800 7f daini-ueno bldg, 3-7-18 tel: 81-45-4781881 9f, no.480, rueiguang rd., neihu district, taipei, 114, taiwan, r.o.c.


▲Up To Search▲   

 
Price & Availability of W79E201A16FN

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X